Attempted to access index from array of length 0! error

I am getting errors in my blueprint where I set the style for my inventory widget. This is what the error looks like.

This is my blueprint.

It won’t let me upload the last picture but it is exactly the same as the other picture where the style is being set, it is just attached to the other set style node.

The inventory I set up seems to be working fine, but I get all these errors. Does anyone know how I can fix this, or what causes this error? Also if you need more information I can get it. Thanks!

Does this help? Also sorry about my lack of knowledge, I have only been using this engine for a few days and I have little coding experience.

that is just saying that your array is empty. your script is trying to get indexes that dont exist so its causing errors. without seeing your loop its hard to say how to fix it but i would start by using a print string and getting the length of your array from within the function. that should at least give you a place to start. other than that i would need to see your loop and the array or at least have a better understanding of your overall script. it may be as simple as setting the array to have default values or a certain length from runtime.

im assuming its a slot based inventory and the errors are due to empty slots which cant receive the style modifications. or something like that

Nevermind, I ended up figuring it out. You pushed me in the right direction, thanks!

1 Like

What was your solution? I think we’re following the same tutorial here and I just ran into this road bump :slight_smile:

It would be respectful to post your solution for others to view…

1 Like

Ok, so I figured it out. Add some is valid indexs and branches in your flow to solve the issue. I assume this was following the titanic games rpg tutorial series, so check out the UI Inventory Event graph and Set Widget Style Functions respectively if you are following that tutorial.

1 Like

This may not be exactly similar to what this post is… but someone who landed here like I did may be experiencing something similar to my problem. I had an Array where and I wanted to get random item from it. So I put in random integer in range 0 min and Length -1 as maximum, but I kept getting an error. For me it turned out that my “empty” array wasn’t empty, it had blank for index 0. So I had to use the Clear array node in the other blue print where I was resetting array values. So my empty was actually empty and all indexes would come out as true.