Gotta_Sweep

ROBLOX Day/Night Cycle

Apr 1st, 2019
3,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. --here Is A Day And Night Cycle For ROBLOX, Put this as a script not a local script, then put it in workspace.
  2. local minutes = 0
  3. local hours = 12
  4.  
  5. local minutesPerGameDay = script.MinutesPerGameDay.Value
  6. local minutesPerSecond = (24/minutesPerGameDay)
  7. local curTime = tick()
  8. local prevTime
  9.  
  10. while wait() do
  11. prevTime = curTime
  12. curTime = tick()
  13. local dt = curTime - prevTime
  14. minutes = minutes + (minutesPerSecond * dt)
  15. if minutes >= 60 then
  16. minutes = minutes - 60
  17. hours = hours + 1
  18. if hours >= 24 then
  19. hours = 0
  20. end
  21. end
  22. game.Lighting.TimeOfDay = hours .. ":" .. math.floor(minutes) .. ":00"
  23. end
  24.  
  25. --If it doesn't work then oof.
Advertisement
Add Comment
Please, Sign In to add comment