hello, I tried to make a click detector part that makes it so when you click it, it changes from day to night and when you click it again it changes from night to day. but for some reason it didn't work and I couldn't seem to find the problem.
here's my code:
local db = false script.Parent.ClickDetector.MouseClick:Connect(function() if db == false then game.Lighting.ClockTime = 0 db = true end if db == true then db = false game.Lighting.ClockTime = 14 end end)
Any help would be greatly appreciated!
You'll want to use elseif instead of separate if statements, the first statement makes it so that the second one always fires. Ex:
local db = false script.Parent.ClickDetector.MouseClick:Connect(function() if db == false then game.Lighting.ClockTime = 0 db = true elseif db == true then db = false game.Lighting.ClockTime = 14 end end)