Executing a script every hour?

Hey! I’m trying to make a script activate every hour (:00) ! I have a ‘real time script’ in-game that matches a specific timezone in real life.

Right now, I have this method:

if script.StartTime.Value == game.Lighting.TimeOfDay then

print ("Oh look, an hour has passed.")

	end

Although, using this method would mean I’d need 24 different scripts to do this… is there an easier way to check if the time in-game is at an hour (example: 1pm, 1am, 5pm, 3am etc…) and then print the message?

1 Like

You can compare ClockTime and detect if it is integer

local ClockTime = game:GetService("Lighting").ClockTime
if math.floor(ClockTime) == ClockTime then
	-- your code
end
2 Likes