Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I disable SC with a SC?

Asked by 10 years ago

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

3 answers

Log in to vote
0
Answered by 10 years ago

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.

Ad
Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
10 years ago

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

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 ? TrunksTakaski 20 — 10y
0
Set disable to false, not enable to true. GoldenPhysics 474 — 10y
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. duckwit 1404 — 10y
Log in to vote
0
Answered by 10 years ago

All scripts have a Disabled property.

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

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

Answer this question