Global variables don't reset between quick previews

If i declare global variables and preview my game (without previewing it on a new server), global variables don’t reset. So i always need to preview on a new server or reset them manually.


Hello. I’ve just flagged this up with the team and will get back to you with a response. Thanks :slight_smile:

1 Like

In this case what’s happening is that the global variable isn’t reset because the preview server is not closed between transitions between it and the editor server.

So after speaking with the team they advise to avoid global variables where possible and instead everything should be scoped to a script instance. This will help ensure compatibility with future updates. With on-going work on the engine we can’t guarantee that logic around global variables won’t break in the future.

Hope that helps!