Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop a local script from running when you reset?

I'm trying to have it so my local script will only run once, so when you click a play button, the script will be destroyed. Of course when I do this and I reset, the code from that script still runs. Is there anyway that I can make the script only run once?

2 comments

0

what

0

call script:Destroy() when you're finished with it, or set the 'Disabled' property to true

1 answer

If you've got your localscript inside of a ScreenGui then that's because of the property "ResetOnSpawn". If you toggle that property off then your script along with the gui won't be reset on spawn.

If you want your gui stuff to reset on spawn but your script not, you can move your localscript to StarterPlayer > StarterPlayerScripts. Anything that's placed in there will not reset

Destroying the localscript or setting it to disable will not work because the game creates a clone of all then content inside of ScreenGui before the game starts. And replaces the old ScreenGui with the cloned version.

This discussion is preserved as it was. New answers, comments, and votes are closed.