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

Buttons controlling lights?

Asked by 9 years ago

So I have a theory, when you want to turn let's say a light bar on for a fire truck. When you want to do this you click a already programmed button (brick) that enables the script and starts the lights up. Well I am trying to move on past this. I want to turn them on using a screengui button instead of a brick button. This screengui button would still do the exact same thing except it would be a button on the screen and easier to access. Is this easy to do? What would I need in order to do it? I already have the lights, the screengui, some scripts, I just need someone to walk me through the entire thing. And remember there would be more than one of these in a game at a time so they would have to be grouped together or named differently for each one. Naming wouldn't be much of a problem because each unit has its own unit ID or number. Thank you very much, just looking for answers.

P.S. I am a beginner scripter and know somewhat of the basics. I can so a simple facelift on a script but other than that I cannot do much else.

2 answers

Log in to vote
0
Answered by 9 years ago

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

script.Parent.Parent.A.BrickColor = BrickColor.new("Really red") 
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("Really red") 
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("Really red") 
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.G.BrickColor = BrickColor.new("Really red") 
script.Parent.Parent.G.Reflectance=0 

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

script.Parent.Parent.J.BrickColor = BrickColor.new("Really red") 
script.Parent.Parent.J.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.G.BrickColor = BrickColor.new("Medium stone grey") 
script.Parent.Parent.G.Reflectance=0 

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

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

wait(0.1)

end end end

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

Ad
Log in to vote
-1
Answered by 9 years ago

I see what you mean. Basically, just put a PointLight or SpotLight inside whichever Brick is your light. Then change the Light's brightness to 0, so it emits no light. Go into the StarterGui and insert a ScreenGui, and inside the ScreenGui and two TextButtons. Edit the first TextButton however you want, and name it Open, then put a script that looks something like this inside of it:

light = game.Workspace.FireTruck1.Brick.PointLight --change this to the Hierarchy for the light

function LightOn()
    light.Brightness = 10
    light.Range = 30
end

script.Parent.MouseButton1Down:connect(LightOn)

Then get the second TextButton and name it Close. Put a script that looks like this inside of it:

light = game.Workspace.FireTruck1.Brick.PointLight --the same Hierarchy as the original light

function LightOff()
    light.Brightness = 0
    light.Range = 0
end

script.Parent.MouseButton1Down:connect(LightOff)

It's really that simple. Hope this helped!

0
Alright but it needs to have a pattern to the lights, this would be a set of lights such as 7 or 10 lights. Here is an example of one of the scripts that needs to be activated: Ffbryce1 0 — 9y

Answer this question