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

How do I get the GUI to disable one script and activate the other but do back and forth?

Asked by 10 years ago

So this is a script and this is the original,

On=false 
function onClicked() 
if On then On=false else 
On=true 
while On do 

    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Medium stone grey") 

    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Really red")  

    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Medium stone grey")

    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Really red")

    wait(0.1)

    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Really red") 

    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Medium stone grey")

    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Really red")

    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Medium stone grey")

    wait(0.1)

    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Medium stone grey") 

    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Medium stone grey") 

    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Medium stone grey")

    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Medium stone grey") 

    wait(0.1)
end 
end
end

script.Parent.MouseButton1Down:connect(onClicked) 

That is all squared away and finished, now I made this script to be turned on when the other one is turned off so the other one turns off and immediately this comes on to shut it all down

On=false 
function onClicked() 
if On then On=false else 
On=true 
while On do 

    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Medium stone grey") 

    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Medium stone grey")  

    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Medium stone grey")

    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Medium stone grey")

    wait(0)
end 
end
end

script.Parent.MouseButton1Down:connect(onClicked) 

And I am not sure how I want to go about this, I have tried many different ways and it is too much for me to handle. But that is what I have on the bottom and it is not working. I want the "Lights" to turn off the second I click. Is there a way to disable or enable the script? I am very lost and need someone to finish the puzzle. This is the last tiny bit of help I need and then I will be done and finished with my project. Does anybody have any ideas?

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

Instead of disabling and enabling scripts you could simply make it so while the variable on is false, it makes sure all the lights are off, and while it's true, the lights go through their flashing cycle.

local on = false

script.Parent.MouseButton1Down:connect(onClicked)
    if not on then
        on = true
    elseif on then
        on = false
    end
end)

while on do 
    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Medium stone grey") 
    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Really red")  
    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Medium stone grey")
    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Really red")
    wait(0.1)
    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Really red") 
    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Medium stone grey")
    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Really red")
    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Medium stone grey")
    wait(0.1)
    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Medium stone grey") 
    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Medium stone grey") 
    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Medium stone grey")
    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Medium stone grey") 
    wait(0.1)
end

while not on do 
    game.Workspace.Test2.Light1.BrickColor = BrickColor.new("Medium stone grey") 
    game.Workspace.Test2.Light2.BrickColor = BrickColor.new("Medium stone grey")  
    game.Workspace.Test2.Light3.BrickColor = BrickColor.new("Medium stone grey")
    game.Workspace.Test2.Light4.BrickColor = BrickColor.new("Medium stone grey")
    wait()
end 
0
This did not work, I see where you are getting at but I am new to scripting so I am not much help. I tried to edit it some and failed. Ffbryce1 0 — 10y
0
Is the script's parent a GUI object? BlackJPI 2658 — 10y
Ad

Answer this question