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

Trying To Make A Day And Night Script Isn't Working?

Basically The Day Part Is Working And It Prints The Word But When It Reaches Night Nothing Is Printed And I Don't Know Why

Its Meant To Enable An AI Script At Night And Disable During The Day

Here Is My Script:

while true do
	wait(1)
	if game.Lighting.ClockTime > 6.3 and game.Lighting.ClockTime < 18.5 then
		print("Day")
		script.Parent.Disabled = true
	elseif game.Lighting.ClockTime < 6.3 and game.Lighting.ClockTime > 18.5 then
		print("Night")
		script.Parent.Disabled = false
	end
end

2 answers

✓ Accepted answer

I Found My Own Answer:

while true do
	wait(1)
	if game.Lighting:GetMinutesAfterMidnight() > 6.3 * 60 then
		print("Day")
		script.Parent.Disabled = true
	end
	if game.Lighting:GetMinutesAfterMidnight() < 6.3 * 60 then
		print("Night")
		script.Parent.Disabled = false
	end
	
end

You can fix your original code by using or instead of and on line 6 (since the ClockTime can't possibly be < 6.3 and > 18.5 simultaneously), or replacing line 6 with else.

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