i am making an game that requires day time. daytime as in a script that does a moon/sun cycling system. the thing is when the sun is supposed go up the moon does instead.
My code:
local mins = 60/1000 for i = 1, math.huge do game.Lighting:SetMinutesAfterMidnight(i) wait(60) end
no errors nothing just loads the time wrong
I might've interpreted this wrong, but I'm assuming you want a day/night cycle script.
Here's what I would do:
minutesAfterMidnight = 12 * 60 --Change the 12 to the starting time while true do minutesAfterMidnight = minutesAfterMidnight + 0.15 --Change it to how much you want the sun or moon to shift each cycle game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) wait(.05) --Change it to how quickly you want each cycle to go end
The script itself is simple, but here's a basic breakdown:
The initial minutesAfterMidnight
variable defines the starting time. The 12 is the hour and it multiplies it by 60 to get the minute.
It then loops it though, adding 0.15 minutes for every 0.05 seconds that passes in real life. You can play around with those values to get the desired rate. I wouldn't recommend changing the 0.15 value too high as it makes the sun/moon's movement really choppy and weird.
Hope this helps :)