I swear roblox pissed me off so f**kin much sometimes. Please help me with this simple script i do not understand at all why its not working. Its making me very angry.
wait()
local Lights = true
local DB = false
local Thread = coroutine.create(function() -- red flashing lights this part works
for i,x in pairs(workspace.Map.Lights:GetDescendants()) do
if x:IsA("PointLight") then
if x.Name == "RLight" then
spawn(function()
while wait() do
x.Enabled = true
repeat wait() x.Brightness = x.Brightness - 0.01 until x.Brightness <= 0
x.Enabled = false
x.Brightness = 0.75
wait(.5)
end
end)
end
end
end
end)
script.Parent.MouseButton1Click:Connect(function() -- works first time i click but after that it doesnt
if DB then return
else
DB = true
for i,v in pairs(workspace.Map.Lights:GetDescendants()) do
if v:IsA("PointLight") and v.Name == "PointLight" then
v.Enabled = not v.Enabled
end
end
if Lights then
Lights = not Lights
game.SoundService.Alarm:Play()
coroutine.resume(Thread)
else
Lights = not Lights
game.SoundService.Alarm:Stop()
coroutine.yield(Thread)
end
DB = false
end
end)

1 comment
Thank you, i am new to coroutines that is why.