--!strict -- Local environmental profile so the arena and the lobby can use different lighting. local Lighting = game:GetService("Lighting") local Players = game:GetService("Players") local TweenService = game:GetService("TweenService") local player = Players.LocalPlayer local atmosphere = Lighting:FindFirstChildOfClass("Atmosphere") local bloom = Lighting:FindFirstChildOfClass("BloomEffect") local sunRays = Lighting:FindFirstChildOfClass("SunRaysEffect") local motion = TweenInfo.new(.55, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut) local day = { ClockTime = Lighting.ClockTime, Brightness = Lighting.Brightness, EnvironmentDiffuseScale = Lighting.EnvironmentDiffuseScale, EnvironmentSpecularScale = Lighting.EnvironmentSpecularScale, } local dusk = { ClockTime = 17.86, Brightness = 1.36, EnvironmentDiffuseScale = .84, EnvironmentSpecularScale = .82, } local clearAir = if atmosphere then { Density = atmosphere.Density, Offset = atmosphere.Offset, Haze = atmosphere.Haze, Color = atmosphere.Color, Decay = atmosphere.Decay, Glare = atmosphere.Glare, } else nil local duskAir = { Density = .25, Offset = .14, Haze = 1.26, Glare = .08, Color = Color3.fromRGB(186, 188, 228), Decay = Color3.fromRGB(107, 111, 161), } local daytimeBloom = if bloom then {Intensity = bloom.Intensity, Threshold = bloom.Threshold, Size = bloom.Size} else nil local showSunRays = sunRays ~= nil and sunRays.Enabled local grade = Instance.new("ColorCorrectionEffect") grade.Name = "ArenaDuskGrade" grade.Brightness = .006 grade.Contrast = -.014 grade.Saturation = -.12 grade.TintColor = Color3.fromRGB(231, 237, 255) grade.Enabled = false grade.Parent = Lighting local goggles: ColorCorrectionEffect? = nil local gogglesSignal: RBXScriptConnection? = nil local inArena = false local tweens: {Tween} = {} local function showGrade() grade.Enabled = inArena and not (goggles and goggles.Enabled) end local function registerGoggles(effect: Instance) if effect.Name ~= "GogglesColor" or not effect:IsA("ColorCorrectionEffect") then return end if gogglesSignal then gogglesSignal:Disconnect() end goggles = effect gogglesSignal = effect:GetPropertyChangedSignal("Enabled"):Connect(showGrade) showGrade() end local added = Lighting.ChildAdded:Connect(registerGoggles) local current = Lighting:FindFirstChild("GogglesColor") if current then registerGoggles(current) end local function blend(instance: Instance, props: {[string]: any}) local tween = TweenService:Create(instance, motion, props) table.insert(tweens, tween) tween:Play() end local function update() local arena = player:GetAttribute("InArena") == true if arena == inArena then return end inArena = arena for _, tween in tweens do tween:Cancel() end table.clear(tweens) blend(Lighting, if arena then dusk else day) if atmosphere and clearAir then blend(atmosphere, if arena then duskAir else clearAir) end if bloom and daytimeBloom then blend(bloom, if arena then {Intensity = .63, Threshold = 1.52, Size = 23} else daytimeBloom) end if sunRays then sunRays.Enabled = showSunRays and not arena end showGrade() end local zoneSignal = player:GetAttributeChangedSignal("InArena"):Connect(update) update() script.Destroying:Once(function() added:Disconnect() zoneSignal:Disconnect() if gogglesSignal then gogglesSignal:Disconnect() end for _, tween in tweens do tween:Cancel() end grade:Destroy() end)