Scripts run even when disabled, disabling is mostly a lie

This has been bugging me a while, and after scrolling through some unanswered posts, I’m ready to ask again, in present times. Script.Enabled = false is lying. What I mean is usually, it terminates the current thread and stops the script, restarting it if it’s enabled again. Well the issue I and many others have faced is that, the script did not terminate the current thread. Most posts had a while loop which the script probably finished before terminating or never does, but I had a different issue. I don’t have the code at the moment but I can sum it up.

Ai script that would be disabled on start.
Script contents:

animation:Play()
task.wait(30)
game.ReplicatedStorage.RemoteHere:FireAllClients()
--insert code

The funny thing is: the remote fires, and the script errored since it was in server storage and not workspace.
That should not happen, according to documentation and everything. That should NOT happen. Only workaround I can think of (haven’t actually tested) is doing

local clone = script:Clone()
clone.Enabled = false
clone.Parent = script.Parent
script:Destroy()

Something that is worth mentioning is that I used a for loop, but worst case scenario, it somehow fired the remote. It shouldn’t go past the remote and it should terminate the thread. Actually I may have cloned and deleted the old scripts but I can’t remember.

Hope someone can finally answer why this stupid thing happens.

1 Like

what are you trying to do?

you can probably do a more efficient way than giving yourself a headache on this

This is because the script is already running. Reparenting it during runtime does nothing but change the parent, not the thread.

2 Likes

for some reason,
instead of using script.Enabled, I use script.Disabled and i never encounter these problems

1 Like
script.Enabled = false

Is basically the same as:

script.Disabled = true

Though I don’t know why they would add a “Disabled” property even though you can just set the Enabled property to false.

that’s exactly why I stated ‘for some reason’

2 Likes

They renamed Disabled to Enabled but they couldn’t deprecate it.

What? Also, as the documentary states, it should apparently terminate the current thread and stop.