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

lighting stuff help please?

Asked by 9 years ago
repeat
game.Lighting.TimeOfDay = tonumber(game.Lighting.TimeOfDay) + tostring(0.15)
until game.Lighting.TimeOfDay == tostring(3)

I just want this to take lighting's time of day's property's current time and make it equal to itself converted into a number plus 0.15 converted into a string until it's e qual to three, why exactly isnt this working? all output said was

00:38:27.590 - Stack Begin 00:38:27.591 - Script 'Players.RootDirectory.PlayerGui.LocalScript', Line 2 00:38:27.592 - Stack End

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
9 years ago

Your problem here is that you are trying to convert something like this, 14:00:00, into a number. That doesn't work and instead returns nil. There is API however that you can use in order to get what time it is. This script will, very quickly, cycle through the day until it reaches 3:00:00:

repeat
    game:GetService('Lighting'):SetMinutesAfterMidnight(game:GetService('Lighting'):GetMinutesAfterMidnight()+1) -- 1 is the increase increment (how many minutes it goes up by)
    wait() -- Add a longer wait if you want the day to go by slower
until game:GetService('Lighting'):GetMinutesAfterMidnight()/60 == 3 -- Change 3 to the time of day you wish for it to stop at.

Note: If you want it to stop at a more specific time, say 4:32:43, you would have to multiply 4 by 60, add 32, then add 43/60. This would give you the number of minutes past midnight. You would have to adjust the increase increment to be low enough to count that specific and change line 4 to this:

until game:GetService('Lighting'):GetMinutesAfterMidnight() == 272+(43/60)

Ad

Answer this question