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

Detect the time of day?

So im trying to get my script to detect if it's 19:21:00, then it would print "It's 19:21!", but if it's not it would print "It's NOT 19:21!". If I set it in studio it works like a charm, but if I use another script to change the time, it does not work. Help! This is what I have btw

local time = game.Lighting.TimeOfDay -- Just my Variable lol

while wait() do -- To repeatedly check the time of day
	if game.Lighting.TimeOfDay == "19:21:00" then
		print("Its 19:21!")
	elseif game.Lighting.TimeOfDay < "19:21:00" then
		print("Its NOT 19:21!")
	end
end

1 answer

✓ Accepted answer

After chatting with the user I've found two issues, One with him using studio and one with the script. The issue with the script is elseif game.Lighting.TimeOfDay < "19:21:00" then The issue with this is its checking if its before 19:21 NOT if it isn't 19:21 As per Lua's Relational Operators, not equal would be ~= so, it should be elseif game.Lighting.TimeOfDay ~= "19:21:00" then

The next issue is due to not knowing about a studio thing, by default when you are changing properties in the properties tab its being changed from the client side, you want it being changed from the server side since its a server script (and if it was from the client side it would only change for you due to filteringenabled) so the fix to that would be to go to the menu bar on studio and click home, Where it says Current:Client, Click it. After you click that it will change to server-sided mode so then when you change the TimeOfDay property, it will change on the server not the client, so then it will print Its not 19:21!. If this solved the problem, click the mark as solution button so we both get reputation!

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