New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
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 5
14 days 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 61 — 14d
0
call script:Destroy() when you're finished with it, or set the 'Disabled' property to true Feahren 3677 — 14d

1 answer

Log in to vote
0
Answered by
Kate_Ai 307 Moderation Voter
14 days ago
Edited 14 days 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