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

How would this GUI go in order to do this?? [STILL UNRESOLVED]

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

Both scripts are activated once script.Parent is clicked, not when one script is turned off. That's what you need to fix.

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)
    script.Disabled = true -- Made the script disable itself.
end 
end
end

script.Parent.MouseButton1Down:connect(onClicked) 

And for the second script...

function onClicked() 
	if script.Parent.Script1.Disabled == true then -- I think it is Disabled == true but it might be Enabled == false.

    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)
    script.Parent.Script1.Disabled = false
end
end

script.Parent.MouseButton1Down:connect(onClicked) 

This script should work. I just made one script disable and the other activate.

1 comment

0

I do not see what that does and it does not work, sorry. I did not understand it at first so I decided maybe I just dont see it so I put it in the model and it did not work like I thought so.

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