How do I display the in game time on a text label?
1 Like
put this inside your TextLabel
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
script.Parent.Text = game.Lighting.ClockTime
end)
How would I format the time so it shows the hour and the minutes only?
you can change ClockTime to TimeOfTheDay if you want it has hours,minutes,secs
I only want it to show hours and minutes not seconds
game.Lighting:GetPropertyChangedSignal("TimeOfDay"):Connect(function()
local HoursNMinutes = string.sub(game.Lighting.TimeOfTheDay,1,5)
script.Parent.Text = HoursNMinutes
end)
1 Like
I think u made a small mistake.
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
local HoursNMinutes = string.sub(game.Lighting.ClockTime,1,2)
script.Parent.Text = HoursNMinutes
end)
yeah i meant to change it to TimeOfDay also you also made a mistake
local HoursNMinutes = string.sub(game.Lighting.ClockTime,1,2)
you have to put TimeOfDay instead of ClockTime
1 Like
https://developer.roblox.com/en-us/api-reference/event/Lighting/LightingChanged
As this event already exists and is fired by the engine you may as well listen for it as opposed to creating your own event listeners via GetPropertyChangedSignal
.