How to update the GUI text (To show the time of day)

Hello there! I’m trying to make a GUI that shows the time of day. The thing is, it’s not showing the time! The text is still just “Label”. Someone told me to “update the GUI”, but I don’t know why. Can you please help? Thank you.

2 Likes

What have you done so far can you show us the script ?

1 Like

Text = script.Parent
On = true
while On do
local TimeOfDay = game.Lighting.TimeOfDay
Text.Text = TimeOfDay
wait(1)
end
Put this in a LocalScript inside the TextLabel you want updated.
Should look something like this: https://streamable.com/hyjtgv

1 Like
--LocalScript in TextLabel
local lighting = game:GetService("Lighting") --obtaining service for .TimeOfDay
lighting:GetPropertyChangedSignal("TimeOfDay"):Connect(function() --fires when .TimeOfDay value changes
    script.Parent.Text = lighting.TimeOfDay --change text to .TimeOfDay
end)

The response above would do, but it yields (making the LocalScript focus on that function, ignoring the rest), and could be unreliable as it updates every 1 second - whereas this listens to when the value changes.

2 Likes

Solved! Thank you @N0b0dym8 and @Doqee !

Ensure to mark a post as a solution - this is to let others know it has been solved from the cover.