game.Lighting.TimeOfDay.Changed:connect(function()
local Time = game.Lighting.TimeOfDay
if Time == "18:00:00" then
print("ITS 18!")
elseif Time == "6:00:00" then
print("ITS 6")
end
end)
What's Wrong with this script?
game.Lighting.TimeOfDay.Changed:connect(function()
local Time = game.Lighting.TimeOfDay
if Time == "18:00:00" then
print("ITS 18!")
elseif Time == "6:00:00" then
print("ITS 6")
end
end)
What's Wrong with this script?
game.Lighting.Changed:connect(function()
local time = game.Lighting:GetMinutesAfterMidnight()
if time == 1080 then
print"It's 6 pm!"
elseif time == 360 then
print"It's 6 am!"
end
end)
Explain what you did.
Well, :GetMinutesAfterMidnight() will do just that, get how many minutes the current time is after midnight. So 6 AM would be 360 minutes after midnight, and 6 PM is 1080 after midnight. To get the minutes after midnight, calculate what the hour is times 60
This Worked! Thanks!
game.Lighting.Changed:connect(function(property)
if property == game.Lighting.TimeOfDay then
if game.Lighting.TimeOfDay == "18:00:00" then
print("ITS 18!")
elseif game.Lighting.TimeOfDay == "6:00:00" then
print("ITS 6")
end
end
end)
You dingus! you can't used the changed event on a specific property, it's meant for instances. Although it returns the property of the instance that was changed. so if we check if the property was TimeOfDay that changed, then we could successfully do the print.
no offense, dingus.
Nope, Does not work.
i'd just use a while loop
The problem with your code jaffer is you had the script looking for the property, not the name. If you were to do it your way, you'd change "if property == game.Lighting.TimeOfDay then" to "if tostring(property) == "TimeOfDay" then"
tostring(property) will return "6:00:00"
No, it will not actually. To find the value of the property, you would have to find it again in the script by using game.Lighting.TimeOfDay.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Your problem is lines 3 and 5 of the code; The 'if' statement is only checking if Variable 'Time' is exactly equal to '1080' or '6:00:00'; 'TimeOfDay' runs by a 24 clock, but, the issue is that your comparing the 'TimeOfDay' to a specific time. :P