Make a working clock that goes with in-game time

Hey! I’m trying to make an analog clock that goes with the current in-game time. There’s a day-night cycle in-game that constantly changes the “time of day” value in Lighting, and I want the clock to go with that time.

I somehow need to get the hour, minute, or second of the time, and somehow turn it into the hand’s orientation. In case you don’t know, in studio hours go up to 24 and minutes and seconds go to 60. I think it will also have to change position as well, so that the bottom of the hand is always in the middle of the clock, but I can probably do this on my own. Any tips on how to do so?

If you have any questions, feel free to ask them! This is one of my first posts, so if the structure is weird that’s why!

1 Like
task.spawn(function()
	while task.wait() do
		local currTime = game.Lighting.TimeOfDay
		local splitTime = string.split(currTime, ":")
		local hours = splitTime[1]
		local minutes = splitTime[2]
		local seconds = splitTime[3]
		print(hours, minutes, seconds)
	end
end)
3 Likes

Thank you!! This helps so much with so many things!!!
Now do you have any idea to convert the number into an orientation? So it points to the hour and stuff.

1 Like

Wow! I was looking for it too Thank you so much!

2 Likes

I think I found a solution to convert the time to an orientation!
For hours, I’ll just set it to 360° / 12, which is 30, then multiply it by the current hour. 6 x 30 would be 180° which would work!
For the minutes and seconds it would be something similar. 360° / 60, which is 6, multiplied by the current min/sec.

So if the time is 8:35:42 (random time), the orientation for hours would be 240°, minutes would be 210°, and seconds would be 252°
This would work for hours over 12 also! If hour is 20, the orientation would just be 600.

Hopefully that helps people with the same problem! I haven’t tested it yet, so if this doesnt work ill delete this post, but in theory it should!

Not sure how to make the bottom of the hand stays in the middle though… If I find a solution I’ll link a post, or just explain it there

1 Like