Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by
jetape 7
6 months 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 — 6mo
0
call script:Destroy() when you're finished with it, or set the 'Disabled' property to true Ziffixture 5655 — 6mo

1 answer

Log in to vote
0
Answered by
ScuffedAI 441 Moderation Voter
6 months ago
Edited 6 months 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