Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Day/night cycle activated script doesn't work?

while wait(1)do
	if game.Lighting.ClockTime >= 20 and game.Lighting.ClockTime <= 7 then
		script.Parent.SpotLight.Enabled = true
		print("light on")
	else
		script.Parent.SpotLight.Enabled = false
		print("light off")
	end
end

I've tested it on local scripts and tried different variations of it. I get the prints but the light doesn't work. Yes, the script is committed.

2 comments

1

The ClockTime cannot be greater than 20 and less than 7 at the same time

0

i think you may want to replace the "and" with an "or"

1 answer

✓ Accepted answer

Replace and with or, or the else code will always run.

This discussion is preserved as it was. New answers, comments, and votes are closed.