NHK = workspace.sss
night = game.Lighting.TimeOfDay
if night >= 6 then
NHK:Play()
end
So basically once the time of day turns night (6) then it'll play this song that my variable labeled "NHK". My script is not working for some reason..
NHK = workspace.sss
night = game.Lighting.TimeOfDay
if night >= 6 then
NHK:Play()
end
So basically once the time of day turns night (6) then it'll play this song that my variable labeled "NHK". My script is not working for some reason..
You would do this by detecting changes to the ClockTime property of the Lighting service, to do this you would use the :GetPropertyChangedSignal function, as the event returned by it only fires when the specified property is changed, rather than all the properties, thus not getting overran by changed events.
ClockTime should be used instead of TimeOfDay in your script as the TImeOfDay property is a string, not a number, which means it can't be compared with other numbers with relational operators. Also, it contains non-digit characters (^%d), which means the tonumber function also won't work. Alernatively, ClockTime is a number value, meaning that it can be compared using relational operators.
local NHK = workspace.sss
local lighting = game.Lighting
lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if lighting.ClockTime >= 6 then
NHK:Play()
end
end
Hopefully this helped!
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
that little space "local NHK" i edited it out
:GetPropertyChangedSignal is a Signal/method. It fires a Listener. Terminology.
oh
Also you forgot to add "end)" because when you use (function() you always need it to end with "end)" a minor mistake but it's alright