Hey everyone, so I am having an issue I was hoping some of you may be able to help explain to me. I created a function in my project. Inside the function, there is a For Each Object Loop which goes through every instance of the object type I'm looking at and runs some code. The problem I am having is that when I run the game the For Loop only fires 1 time if it is part of the Function call. If I take the For Loop out of the function call entirely and make it a separate event it works perfectly and does exactly what I need it to do other than the fact it is running at all times and not just when I use the function. However, once I re-insert the function into the For Each Loop the problem reappears. Does anyone know why this might be happening? For reference I have included some screenshots of the function so you can get a better idea of what I'm saying.
Any help on this would be really appreciated as I think I had this issue with other functions in previous projects and Ive never been able to make it work. Is there something about the way a For Each Loop works inside of a function that I need to be aware of, or is it something else entirely?
Anyway, thanks for any help you canprovide.