Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

lighting stuff help please?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.