Function only runs the last one

Hello. I have a problem with code where when i call function it only runs last one. I tried a lot of different ways to fix it but I’m still new to this program but I still can’t find solution.
What I want to make is when I move tree and it collides with tile, tree positions on center of the tile and it kind of blinks so you can know its positioned well.

Many thanks in advance!

Hi @Ivana_5,

You are overwriting the collision event for each tree in the list, with each subsequent function call - that’s why it only works for the trees & tile in the last function call.

To solve this, use the advanced collision CoBlock with a conditional check on the variable inside the event. See Why is this collision not adding a value to the variable - #3 by techleapnz for an example usage.

Hope this helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

2 Likes