Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I disable SC with a SC?

Is there a way to disable a script with a script, if so how?

3 answers

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).

3 comments

0

o if it was a onClick with a wait time(say if I wanted the enable to happen 5 seconds after the disable) would it be like" game. Workspace.Nameofmyscript.Disable = true wait(5) game.Workspace.NameOfMySCript.Enable = true ?

0

Set disable to false, not enable to true.

0

GoldPhysics is right, there is no "Enabled" property on a Script, you ENABLE the script by setting DISABLED to FALSE, that is how booleans work, they are either on or off.

All scripts have a Disabled property.

Turn script on: game.Workspace.Script.Disabled = false

Turn script off: game.Workspace.Script.Disabled = true

This discussion is preserved as it was. New answers, comments, and votes are closed.