Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this print? To my understanding there is nothing wrong with this, I have no console errors [closed]

Asked by 3 years ago

I have a script that sets the time to 19, and it works, but then this doesn't go through?

if game.Lighting.TimeOfDay == 19 then 
   print("19")
end

Marked as Duplicate by imKirda

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 3 years ago

The reason it is not printing anything is because the if statement is not within a loop. What you can do is use OnChanged() to detect when the time changes, and when it changes, it checks the TimeOfDay and sees if it is 19.

game.Lighting.Changed:Connect(function(changedProperty) --Lighting property is changed
    if game.Lighting.TimeOfDay == 19 then 
        print("19")
    end
end)
Ad