Advertisement
Guest User

Cycle

a guest
May 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. local dayLength = 12
  2.  
  3. local cycleTime = dayLength*60
  4. local minutesInADay = 24*60
  5.  
  6. local lighting = game:GetService("Lighting")
  7.  
  8. local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
  9. local endTime = startTime + cycleTime
  10.  
  11. local timeRatio = minutesInADay / cycleTime
  12.  
  13. if dayLength == 0 then
  14. dayLength = 1
  15. end
  16.  
  17. repeat
  18. local currentTime = tick()
  19.  
  20. if currentTime > endTime then
  21. startTime = endTime
  22. endTime = startTime + cycleTime
  23. end
  24.  
  25. lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
  26. wait(1/15)
  27. until false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement