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

How to make function onClick() disable a script permanently?

Asked by 9 years ago

I made a script that's supposed to disable a script, as well as its subscripts and sounds inside it, and play a message when the button is clicked.

However, after disabling the script and its contents, it re-enabled it. I want the script to be disabled permanently upon clicking the button.

S1 = game.Workspace.SDS

function onClick()
    S1.Disabled = true
    S1.SDS2.Disabled = true
    S1.Alarm0:Stop()
    S1.Alarm1:Stop()
    S1.Alarm2:Stop()
    S1.Alarm3:Stop()
    S1.Alarm4:Stop()
    S1.Fire:Stop()
    S1.movement:Stop()
    script.Parent.ClickDetector.MaxActivationDistance = 0

local hint = Instance.new("Hint", game.Workspace)

hint.Text = "Script Turned Off."
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

1
Why not just destroy the script then? FearMeIAmLag 1161 — 9y
0
I'll be needing the script after it's disabled eventually, as there will be another button to re-enable the script. ChromeNine 50 — 9y
1
Why separate scripts, when you can just compact them together with their own separate functions? Redbullusa 1580 — 9y
0
Actually, I think that would work. Resolved. ChromeNine 50 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

An easy way to do this would be to use a bool value and check if it is true at the beginning of every script. That way you can just have it change the bool value.

Ad
Log in to vote
0
Answered by 9 years ago

I would start the script with an if then statement with a variable that only allows the function to run if its true. Once the script has run once, you can set the variable to false, therefore not allowing the script to run until you make the variable true again.

Answer this question