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

GUI if script disabled breaks other scripts?

So I have a script in my GUI that detects a script in the workspace that if disabled, makes the GUI disappear. However, this just breaks the game instead. Anyone see why?

repeat wait() until game.Workspace.Lights.Sequence.Script.Disabled == false -- This will keep the code from continuing until LoadVal is disabled.

-- Below is what you want to happen when it does.
    script.Parent.BackgroundTransparency = 0.1
    script.Parent.TextButton.TextTransparency = 0.1
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.2
    script.Parent.TextButton.TextTransparency = 0.2
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.3
    script.Parent.TextButton.TextTransparency = 0.3
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.4
    script.Parent.TextButton.TextTransparency = 0.4
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.5
    script.Parent.TextButton.TextTransparency = 0.5
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.6
    script.Parent.TextButton.TextTransparency = 0.6
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.7
    script.Parent.TextButton.TextTransparency = 0.7
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.8
    script.Parent.TextButton.TextTransparency = 0.8
    wait(0.1)
    script.Parent.BackgroundTransparency = 0.9
    script.Parent.TextButton.TextTransparency = 0.9
    wait(0.1)
    script.Parent.BackgroundTransparency = 1
    script.Parent.TextButton.TextTransparency = 1

Cheers,

Michael

2 comments

0

Is the script that is checking this a localscript? Are you attempting to make the code happen when the script is disabled or not disabled?

0

Both scripts are standard scripts.

1 answer

I've often found repeat wait() until -- code is often breaking, so as a backup, I do while loops. I'd probably do this instead:

while game.Workspace.Lights.Sequence.Script.Disabled == false do wait() end

for i = 1,10 do
	script.Parent.TextButton.TextTransparency = script.Parent.TextButton.TextTransparency + 0.1
	script.Parent.BackgroundTransparency = script.Parent.BackgroundTransparency + 0.1
	wait(0.1)
end

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