Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
jetape 9
4 years ago

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?

0
what Lunaify 66 — 4y
0
call script:Destroy() when you're finished with it, or set the 'Disabled' property to true Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by
ScuffedAI 435 Moderation Voter
4 years ago
Edited 4 years ago

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.

Ad

Answer this question