Advertisement
dubleeyrblxx

Day Night Cycle -- Roblox

Jul 5th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. -- Day night cycle
  2. -- Put in ServerScriptService
  3.  
  4. local lighting = game:GetService("Lighting")
  5. local tweenService = game:GetService("TweenService")
  6.  
  7. local dayLength = 250 -- How many real-time seconds an in-game day will last
  8. local nightLength = 150 -- How many real-time seconds an in-game night will last
  9.  
  10. function tween (l, p)
  11.     tweenService:Create(lighting, TweenInfo.new(l, Enum.EasingStyle.Linear, Enum.EasingDirection.In), p):Play()
  12. end
  13.  
  14. lighting.ClockTime = 6
  15.  
  16. while dayLength ~= nil do
  17.    
  18.     tween(dayLength, {ClockTime = 18})
  19.     wait(dayLength)
  20.    
  21.     tween(4, {OutdoorAmbient = Color3.new(60/255, 60/255, 60/255), FogColor = Color3.new(25/255, 25/255, 25/255), FogEnd = 700})
  22.     tween(nightLength / 2, {ClockTime = 24})
  23.     wait(nightLength / 2)
  24.     tween(nightLength / 2, {ClockTime = 6})
  25.     wait(nightLength / 2)
  26.     tween(4, {OutdoorAmbient = Color3.new(140/255, 140/255, 140/255), FogColor = Color3.new(195/255, 195/255, 195/255), FogEnd = 4500})
  27.    
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement