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 ;/
TimeOfDay is returned to you as a string. Change it and check it like this:
if game.Lighting.TimeOfDay:sub(1,2)>=6 then print("Heck yea") end
Or:
game.Lighting.TimeOfDay="06:00:00" --This'll change it to 6 o' clock. You shouldn't check what it is this way.
Try what I did in the first script, and format it to fit into your script correctly. I think you understand how to do it from here, if not leave a comment and i'll see what I can do. Hope I helped :P