i am currently trying to make a textlabel refresh everytime the TimeOfTheDay has changed in the lighting
however i tried using the “changed” function it didnt work so i changed it into while true do but it didnt refresh all the time it just refreshed once and then stopped.
LocalScript Wich Should change its text when TimeOfDay Has changed
local TimeLabel = script.Parent
local timeofday = game.Lighting.TimeOfDay
while true do
TimeLabel.Text = timeofday
end
ServerScript wich changes the time its sum free model i found
l = game:service("Lighting")
while true do
print("Loading...")
wait(0.890)
l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+1)
end
I Would specify myself as lua beginner due to i can modify scripts etc but when i have to write one myself i often struggle with the way on how i should call a function because i dont know the ways how to call one
The reason the while true do loop doesn’t work is because there is no yield. U should use :GetPropertyChangedSignal() to get a event that fires when a specific property gets changed.
:GetPropertyChangedSignal() returns a RBXScriptSignal, to add a Event Listener to ot use :Connect()
Example
game:GetService("Lighting"):GetPropertyChangedSignal("TimeOfDay"):Connect(function() -- Get Lighting service then use : GetPropertyChangedSignal("TimeOfDay") to get a event that fires when TimeOfDay changes.
-- Do stuff here
end)