In game clock GUI

G’day, I want to do a in game clock GUI that shows the player the game time, I already made the GUI but I’m stuck with the script. I tried searching on the internet, but either my clock would freeze or even show the real time!
does anyone have an idea how i can do?

Would this video help you?

1 Like

I’ve already tried it, but it doesn’t work, maybe I’ll try again

Are you trying to sync the clock with a day/night cycle?

long ago i made a simple script to do that:

while wait() do
	local str = game.Lighting.TimeOfDay
	str = str:sub(0,-4)
	script.Parent.Text = str
end

or if you prefer showing seconds (i don’t recommend it because day cycles in games are usually sped up):

while wait() do
	script.Parent.Text = game.Lighting.TimeOfDay
end

the script should be inside a textlabel btw

Thank you, I just forgot to delete an old script that was causing the system to crash.

Isn’t while wait() do the same as while true do? If it isn’t, everyone should be at least replacing wait() with task.wait().

while wait() do
end

and

while true do
wait()
end

are the same

and there’s no need to use task.wait() it’s super accurate because its a short loop