When I click my Police LightBar It turns on but when I click it again it won't turn off. What am I doing wrong?
local lightBar = script.Parent
local blue = lightBar.BlueLight
local blue1 = lightBar.BlueLight1
local red = lightBar.RedLight
local red1 = lightBar.RedLight1
local red2 = lightBar.RedLight2
local function turnOn(part)
part.Material = Enum.Material.Neon
part.SurfaceLight.Enabled = true
end
local function turnOff(part)
part.Material = Enum.Material.Plastic
part.SurfaceLight.Enabled = false
end
local function onClicked(player)
while true do
turnOn(blue)
turnOn(blue1)
turnOff(red)
turnOff(red1)
turnOff(red2)
wait(0.5)
turnOn(red)
turnOn(red1)
turnOn(red2)
turnOff(blue)
turnOff(blue1)
wait(0.5)
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

4 comments
Thanks !
It says that there is an error at : script.Parent.ClickDetector.MouseClick:connect(onClicked)
Okay I figured it out. You were supposed to add another end at line 49. Thanks so much for your help :D
Oh whoops, sorry about that! Your welcome!