Script variables not sticking

Hey Guys,

I’m working on a 2D game, and have a script to hide a door sprite when the player opens the door.

I’ve attached the door sprite to the script variable in the editor, but when I preview the game the variable is empty.

This is edit mode:
2917039--215256--Edit.png

Then when I hit the play button to preview the scene:
2917039--215257--Run.png

When I’m running the game, I can re-attach the door sprite and the script works, but when I preview it again, the variable is empty again.

Are you sure you’re not trying to do something in code that overwrites the sprite? I would suggest showing some code.

2 Likes

That fixed it, I had some code that I thought initialized the variables, but actually overwrote them, thanks!