RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Write me the most complex script for time"
-- script for a complex time system in Roblox local TimeSystem = {} TimeSystem.__index = TimeSystem local function lerp(a, b, t) return a + (b - a) * t end function TimeSystem.new() local self = setmetatable({}, TimeSystem) self.TimeOfDay = 0 self.Speed = 1 self.Running = false self.Lighting = game:GetService("Lighting") self.Lighting.ClockTime = 0 return self end function TimeSystem:SetTime(newTime) self.TimeOfDay = newTime % 24 self.Lighting.ClockTime = self.TimeOfDay end function TimeSystem:SetSpeed(speed) self.Speed = speed end function TimeSystem:Start() self.Running = true while self.Running do self.TimeOfDay = (self.TimeOfDay + self.Speed / 60) % 24 self.Lighting.ClockTime = self.TimeOfDay local t = (math.sin(math.pi * self.TimeOfDay / 12) + 1) / 2 local newAmbient = Color3.fromRGB(lerp(0, 128, t), lerp(0, 128, t), lerp(0, 255, t)) local newOutdoorAmbient = Color3.fromRGB(lerp(0, 128, t), lerp(0, 128, t), lerp(0, 255, t)) local newFogColor = Color3.fromRGB(lerp(0, 192, t), lerp(0, 192, t), lerp(0, 255, t)) self.Lighting.Ambient = newAmbient self.Lighting.OutdoorAmbient = newOutdoorAmbient self.Lighting.FogColor = newFogColor wait(1) end end function TimeSystem:Stop() self.Running = false end local timeSystem = TimeSystem.new() timeSystem:SetTime(12) timeSystem:SetSpeed(1) timeSystem:Start()