Checking the in-game time issue

  1. What do you want to achieve?
    If the gae.Lighting.TimeOfDay is between 20 and 8 for it to work

  2. What is the issue?
    It does not work. Doesn’t throw a error or anything, so it’s a conditional error.

  3. What solutions have you tried so far?
    I tried printing what the TimeOfDay was and it didn’t help me at all.

local TimeOfDay = 0.1
local TimeAdd = 0.001

local NoticedNight = false

while task.wait(TimeOfDay) do
	game:GetService("Lighting").ClockTime += TimeAdd
end

game:GetService("RunService").Stepped:Connect(function()
	if (game:GetService("Lighting").ClockTime < 8 and game:GetService("Lighting").ClockTime > 20) and NoticedNight == false then
		NoticedNight = true
		TimeOfDay = 0.05
		print("it's night")
	end
end)


You check if the time is lower than 8 and higher than 20, but it should be reversed if you want to check if it’s in between.

1 Like

It’s a and statement so I don’t think it will change much but will try.
Edit: Tried it and still didn’t work.

	if (game:GetService("Lighting").ClockTime > 8 and game:GetService("Lighting").ClockTime < 20) and NoticedNight == false then

I meant that you should reverse the relational operators < and >. Check if it’s higher than 8 and lower than 20.

That’s what I did but it seems I sent the wrong code. One sec.

For what? Setting the time isn’t the issue, it’s checking if the time is in-between a certain time.