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

How to check if the ClockTime is between [X] then do code?

I have a script that I want when it's between a certain ClockTime then it does code, however I'm unsure on what I should be doing. Here's my script for reference:

while true do
	local l = game.Lighting.ClockTime
	if l ????? then
		--CODE HERE
	end
end

In the question marks I want to check if the ClockTwice is between 12am and 6am if so then do code, but I have no idea on what I should be doing

1 answer

✓ Accepted answer
while true do
    local l = game.Lighting.ClockTime
    if l <= 6 and l >= 0 
        --CODE HERE
    end
    wait()
end

In here, you will need to substitute X for the highest amount of time it can be, and Y for the lowest amount of time it can be. Also, note that time is used in military time, so it goes from 0 to almost 24(0 is also 24, so thats why its almost).

You also need a wait() or else the loop will crash the game.

Hopefully this helps you!

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