I am trying to make it so when you click a Button, it makes a PointLight go on and off for a set time, but I am stuck on the "else" part.
script.Parent.MouseButton1Click:connect(function() if game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled == false then while true do game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled = true wait(1) game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled = false end else game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled = false end end)
x = false script.Parent.MouseButton1Click:connect(function() if x == false then script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Enabled = true x = true end if x == true then script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Enabled = true x = false end end)
This is an Off/On Switch.
If I answered this question Check Mark :)
a = script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Enabled b = false script.Parent.MouseButton1Click:connect(function() if b == false then b = true while b == true do a = true wait(0.1) a = false end elseif b == true then b = false a = false end end)
EDIT #1
You need it an If Statement, this should work.
if script.Parent.MouseButton1Click then while true do wait(1) script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Range = 60 print("Button Clicked") else script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Range = 0 end end