Is there a way to disable a script with a script, if so how?
Let's say that the scriptyou want to disabled is in the Workspace. And is called NeedsToBeDisabled, then simply do this code:
game.Workspace.NeedsToBeDisabled.Disabled = true
In other words every script has a [Disabled] property.
The Disabled
property exists on all Script
Instances, so as long as you can get an object path (like game.Workspace.YourScript
) to the Script
, then you can disable it!
game.Workspace.NameOfYourScript.Disabled = true
You can, of course, also disable a Script
from inside itself using the script
self-reference:
script.Disabled = true
If you want to re-enable it after that, set the Disabled
property to false
, this will reinitiate the script (from the start).
All scripts have a Disabled
property.
Turn script on: game.Workspace.Script.Disabled = false
Turn script off: game.Workspace.Script.Disabled = true