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

Using a screengui to turn on a light pattern?

Asked by 9 years ago

So currently I use a button named, "I" to control a lightbar. Inside "I" there is a script called, "A". When I is clicked on, "A" is activated therefore activating the pattern. I figure there has to be an easy way to make a button with a screengui and have it do the exact same thing. Just thinking they are both buttons except one is always on the screen and one is an actual brick. Is there an easy way to do this? I already have the screengui and the button. I also have the lightbar which has bricks, A-F,"I", and J-M. This is the script that gets activated:

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

script.Parent.Parent.A.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.A.Reflectance=0 

script.Parent.Parent.B.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.B.Reflectance=0 

script.Parent.Parent.C.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.C.Reflectance=0 

script.Parent.Parent.D.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.D.Reflectance=0 

script.Parent.Parent.E.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.E.Reflectance=0 

script.Parent.Parent.F.BrickColor = BrickColor.new("White") 
script.Parent.Parent.F.Reflectance=0 

script.Parent.Parent.J.BrickColor = BrickColor.new("White") 
script.Parent.Parent.J.Reflectance=0 

script.Parent.Parent.K.BrickColor = BrickColor.new("White") 
script.Parent.Parent.K.Reflectance=0 

script.Parent.Parent.L.BrickColor = BrickColor.new("White") 
script.Parent.Parent.L.Reflectance=0 

script.Parent.Parent.M.BrickColor = BrickColor.new("White") 
script.Parent.Parent.M.Reflectance=0 

wait(0.1) 

script.Parent.Parent.A.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.A.Reflectance=0

script.Parent.Parent.B.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.B.Reflectance=0  

script.Parent.Parent.C.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.C.Reflectance=0 

script.Parent.Parent.D.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.D.Reflectance=0 

script.Parent.Parent.E.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.E.Reflectance=0 

script.Parent.Parent.F.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.F.Reflectance=0 

script.Parent.Parent.J.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.J.Reflectance=0 

script.Parent.Parent.K.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.K.Reflectance=0 

script.Parent.Parent.L.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.L.Reflectance=0 

script.Parent.Parent.M.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.M.Reflectance=0 

wait(0.1) 

end end end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

0
This pattern just loops but I removed the loop because it would be long. Ffbryce1 0 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

This is pretty easy. Go into startergui and make the button if you have not already (make sure to put in a screengui!). Then copy your script inside the button and replace

script.Parent.ClickDetector.MouseClick:connect(onClicked)

with

script.Parent.MouseButton1Click:connect(onClicked)

That event is like clickdetectors mouse click, but it is for GUI buttons.

0
Sorry for no right code highlighting it always hates me. figgycity50 70 — 9y
0
Just make sure the tills get lines to themselves. Try typing all of your code, selecting it, then pressing code block. GoldenPhysics 474 — 9y
Ad

Answer this question