Global line of code

I want for a function to only run when an object collides with the player. But because of the global, it runs anyway. How do I stop it?

A global will always output its value once updated. Instead, you should have the global only input into the “Set” of the number and have the collision only into the “Get” of the number

2 Likes

Its not working,the program continues

Yeah just use number, global set the number.

1 Like

Use a switch, if you need it to output once it hits the player, make it so when the collision happens it turns on the switch

Actually, yeah, this would be better

1 Like

Switch is more complicated

1 Like

Remove the get input from the global to the number. And instead connect that to the collision output. Also, what is the purpose of setting the global?

so i can use it in different objects