What I'm trying to achieve with this script is:
There's a NumberValue within each player in the game, I want the script to set it to 0 after TimeOfDay changes to 6:00:00 or more, but I only want it to change once that time has passed, and then leave it.
local players = game.Players:GetPlayers()
local currentTime = game.Lighting:GetMinutesAfterMidnight()/60
game.Lighting.Changed:connect(function(prop)
if prop == "TimeOfDay" then
if currentTime >= 6 and currentTime < 20 then
for i = 1, #players do
players[i].Tiredv.Value = 0
print'changed'
end end
else
print'not time'
end
end)
After trying what @alphawolvess said,
I have this:
local players = game.Players:GetPlayers()
local currentTime = game.Lighting:GetMinutesAfterMidnight()/60
game.Lighting.Changed:connect(function()
if game.Lighting.TimeOfDay == "06:00:00" then
for i = 1, #players do
players[i].Tiredv.Value = 0
print'changed'
end
else
print'not time'
end
end)
And that still isn't working, I've tried 'game.Lighting.LightingChanged:connect(function()', and that also isn't working. Any ideas why this script might not be working as the script tells it to?
It prints 'not time', but when time == 06:00:00 it doesn't run the if statement... Hmm ;/

2 comments
TimeOfDay is used in string: game.Lighting.TimeOfDay = "6:00:00". Also, try to use LightingChanged instead of Changed.
I think this would best be done via LocalScript unless you've got FilteringEnabled on. Do you have it on? If you don't, I'll whip up a script that should work.