local Players = game:GetService("Players") local Lighting = game:GetService("Lighting") local StarterGui = game:GetService("StarterGui") local CoreGui = game:GetService("CoreGui") local LocalPlayer = Players.LocalPlayer or Players.PlayerAdded:Wait() if not game:IsLoaded() then game.Loaded:Wait() end local sharedEnv = (type(getgenv) == "function" and getgenv()) or _G if type(sharedEnv.__UNIVERSAL_ANTILAG_UI_CLEANUP) == "function" then pcall(sharedEnv.__UNIVERSAL_ANTILAG_UI_CLEANUP) end local runtimeConnections = {} local changedProperties = {} local antiLagEnabled = false local descendantConnection local gui local oldQualityLevel local oldSavedQualityLevel local function addConnection(conn) table.insert(runtimeConnections, conn) return conn end local function disconnectConnection(conn) if conn then pcall(function() conn:Disconnect() end) end end local function safeGet(instance, propertyName) local ok, value = pcall(function() return instance[propertyName] end) return ok and value or nil end local function safeSet(instance, propertyName, value) pcall(function() instance[propertyName] = value end) end local function rememberProperty(instance, propertyName) if not instance then return end local data = changedProperties[instance] if not data then data = {} changedProperties[instance] = data end if data[propertyName] == nil then data[propertyName] = safeGet(instance, propertyName) end end local function rememberAndSet(instance, propertyName, value) if not instance then return end rememberProperty(instance, propertyName) safeSet(instance, propertyName, value) end local function shouldSkip(instance) if not instance then return true end local character = LocalPlayer.Character if character and instance:IsDescendantOf(character) then return true end return false end local function optimizeInstance(instance) if shouldSkip(instance) then return end if instance:IsA("BasePart") then rememberAndSet(instance, "Material", Enum.Material.SmoothPlastic) rememberAndSet(instance, "Reflectance", 0) rememberAndSet(instance, "CastShadow", false) if instance:IsA("MeshPart") then rememberAndSet(instance, "RenderFidelity", Enum.RenderFidelity.Performance) rememberAndSet(instance, "TextureID", "") end elseif instance:IsA("Decal") or instance:IsA("Texture") then rememberAndSet(instance, "Transparency", 1) elseif instance:IsA("ParticleEmitter") or instance:IsA("Trail") or instance:IsA("Beam") or instance:IsA("Smoke") or instance:IsA("Fire") or instance:IsA("Sparkles") then rememberAndSet(instance, "Enabled", false) elseif instance:IsA("PointLight") or instance:IsA("SpotLight") or instance:IsA("SurfaceLight") then rememberAndSet(instance, "Enabled", false) elseif instance:IsA("SpecialMesh") then rememberAndSet(instance, "TextureId", "") elseif instance:IsA("SurfaceAppearance") then rememberAndSet(instance, "ColorMap", "") rememberAndSet(instance, "MetalnessMap", "") rememberAndSet(instance, "NormalMap", "") rememberAndSet(instance, "RoughnessMap", "") end end local function optimizeLighting() rememberAndSet(Lighting, "Technology", Enum.Technology.Compatibility) rememberAndSet(Lighting, "GlobalShadows", false) rememberAndSet(Lighting, "FogEnd", 1e9) rememberAndSet(Lighting, "ShadowSoftness", 0) for _, effect in ipairs(Lighting:GetChildren()) do if effect:IsA("PostEffect") then rememberAndSet(effect, "Enabled", false) elseif effect:IsA("Atmosphere") then rememberAndSet(effect, "Density", 0) rememberAndSet(effect, "Haze", 0) rememberAndSet(effect, "Glare", 0) elseif effect:IsA("Sky") then rememberAndSet(effect, "CelestialBodiesShown", false) rememberAndSet(effect, "StarCount", 0) end end end local function optimizeTerrain() local terrain = workspace:FindFirstChildOfClass("Terrain") if not terrain then return end rememberAndSet(terrain, "Decoration", false) rememberAndSet(terrain, "WaterWaveSize", 0) rememberAndSet(terrain, "WaterWaveSpeed", 0) rememberAndSet(terrain, "WaterReflectance", 0) rememberAndSet(terrain, "WaterTransparency", 1) end local function restoreAllProperties() for instance, propertyData in pairs(changedProperties) do if instance and instance.Parent then for propertyName, oldValue in pairs(propertyData) do safeSet(instance, propertyName, oldValue) end end changedProperties[instance] = nil end end local function setLowestQuality() pcall(function() local rendering = settings().Rendering if oldQualityLevel == nil then oldQualityLevel = rendering.QualityLevel end rendering.QualityLevel = Enum.QualityLevel.Level01 end) pcall(function() local userGameSettings = UserSettings():GetService("UserGameSettings") if oldSavedQualityLevel == nil then oldSavedQualityLevel = userGameSettings.SavedQualityLevel end userGameSettings.SavedQualityLevel = Enum.SavedQualitySetting.QualityLevel1 end) end local function restoreQuality() if oldQualityLevel ~= nil then pcall(function() settings().Rendering.QualityLevel = oldQualityLevel end) end if oldSavedQualityLevel ~= nil then pcall(function() local userGameSettings = UserSettings():GetService("UserGameSettings") userGameSettings.SavedQualityLevel = oldSavedQualityLevel end) end end local function notify(text) pcall(function() StarterGui:SetCore("SendNotification", { Title = "Universal Anti-Lag", Text = text, Duration = 3, }) end) end local function enableAntiLag() if antiLagEnabled then return end antiLagEnabled = true setLowestQuality() optimizeLighting() optimizeTerrain() for _, instance in ipairs(workspace:GetDescendants()) do optimizeInstance(instance) end descendantConnection = addConnection(workspace.DescendantAdded:Connect(function(instance) if antiLagEnabled then optimizeInstance(instance) end end)) notify("Enabled") end local function disableAntiLag() if not antiLagEnabled then return end antiLagEnabled = false disconnectConnection(descendantConnection) descendantConnection = nil restoreAllProperties() restoreQuality() notify("Disabled") end local function getUiParent() if type(gethui) == "function" then local ok, hui = pcall(gethui) if ok and hui then return hui end end if CoreGui then return CoreGui end local playerGui = LocalPlayer:FindFirstChildOfClass("PlayerGui") if playerGui then return playerGui end return LocalPlayer:WaitForChild("PlayerGui") end local function makeGradient(parent, colorA, colorB, rotation) local gradient = Instance.new("UIGradient") gradient.Color = ColorSequence.new(colorA, colorB) gradient.Rotation = rotation or 0 gradient.Parent = parent return gradient end local function createUi() local screenGui = Instance.new("ScreenGui") screenGui.Name = "UniversalAntiLagUI" screenGui.ResetOnSpawn = false screenGui.IgnoreGuiInset = true screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling screenGui.DisplayOrder = 999999 screenGui.Parent = getUiParent() local openShadow = Instance.new("Frame") openShadow.Name = "OpenShadow" openShadow.AnchorPoint = Vector2.new(0, 1) openShadow.Position = UDim2.new(0, 19, 1, -63) openShadow.Size = UDim2.fromOffset(140, 44) openShadow.BackgroundColor3 = Color3.fromRGB(0, 0, 0) openShadow.BackgroundTransparency = 0.55 openShadow.BorderSizePixel = 0 openShadow.ZIndex = 9 openShadow.Parent = screenGui local openShadowCorner = Instance.new("UICorner") openShadowCorner.CornerRadius = UDim.new(0, 14) openShadowCorner.Parent = openShadow local openButton = Instance.new("TextButton") openButton.Name = "OpenButton" openButton.AnchorPoint = Vector2.new(0, 1) openButton.Position = UDim2.new(0, 16, 1, -66) openButton.Size = UDim2.fromOffset(140, 44) openButton.BackgroundColor3 = Color3.fromRGB(34, 137, 255) openButton.BorderSizePixel = 0 openButton.Font = Enum.Font.GothamBold openButton.Text = "Anti-Lag" openButton.TextSize = 16 openButton.TextColor3 = Color3.fromRGB(255, 255, 255) openButton.AutoButtonColor = false openButton.ZIndex = 10 openButton.Active = true openButton.Draggable = true openButton.Parent = screenGui local openCorner = Instance.new("UICorner") openCorner.CornerRadius = UDim.new(0, 14) openCorner.Parent = openButton local openStroke = Instance.new("UIStroke") openStroke.Thickness = 1.3 openStroke.Transparency = 0.25 openStroke.Color = Color3.fromRGB(255, 255, 255) openStroke.Parent = openButton makeGradient(openButton, Color3.fromRGB(63, 166, 255), Color3.fromRGB(43, 115, 255), 25) local function syncOpenShadow() openShadow.Position = UDim2.new( openButton.Position.X.Scale, openButton.Position.X.Offset + 3, openButton.Position.Y.Scale, openButton.Position.Y.Offset + 3 ) openShadow.Size = openButton.Size end syncOpenShadow() addConnection(openButton:GetPropertyChangedSignal("Position"):Connect(syncOpenShadow)) addConnection(openButton:GetPropertyChangedSignal("Size"):Connect(syncOpenShadow)) local panel = Instance.new("Frame") panel.Name = "Panel" panel.AnchorPoint = Vector2.new(0.5, 0.5) panel.Position = UDim2.new(0.5, 0, 0.5, 0) panel.Size = UDim2.fromOffset(300, 190) panel.BackgroundColor3 = Color3.fromRGB(15, 20, 31) panel.BorderSizePixel = 0 panel.Visible = false panel.ZIndex = 20 panel.Active = true panel.Draggable = true panel.Parent = screenGui local panelCorner = Instance.new("UICorner") panelCorner.CornerRadius = UDim.new(0, 14) panelCorner.Parent = panel local panelStroke = Instance.new("UIStroke") panelStroke.Thickness = 1.3 panelStroke.Transparency = 0.2 panelStroke.Color = Color3.fromRGB(74, 126, 255) panelStroke.Parent = panel makeGradient(panel, Color3.fromRGB(20, 28, 43), Color3.fromRGB(12, 16, 27), 90) local title = Instance.new("TextLabel") title.BackgroundTransparency = 1 title.Position = UDim2.fromOffset(14, 10) title.Size = UDim2.fromOffset(220, 24) title.Font = Enum.Font.GothamBold title.Text = "Universal Anti-Lag" title.TextSize = 18 title.TextXAlignment = Enum.TextXAlignment.Left title.TextColor3 = Color3.fromRGB(235, 241, 255) title.ZIndex = 21 title.Parent = panel local closeBtn = Instance.new("TextButton") closeBtn.BackgroundColor3 = Color3.fromRGB(255, 86, 86) closeBtn.Position = UDim2.new(1, -34, 0, 10) closeBtn.Size = UDim2.fromOffset(24, 24) closeBtn.BorderSizePixel = 0 closeBtn.Font = Enum.Font.GothamBold closeBtn.Text = "X" closeBtn.TextSize = 12 closeBtn.TextColor3 = Color3.fromRGB(255, 255, 255) closeBtn.AutoButtonColor = false closeBtn.ZIndex = 21 closeBtn.Parent = panel local closeCorner = Instance.new("UICorner") closeCorner.CornerRadius = UDim.new(0, 8) closeCorner.Parent = closeBtn local info = Instance.new("TextLabel") info.BackgroundTransparency = 1 info.Position = UDim2.fromOffset(14, 42) info.Size = UDim2.fromOffset(272, 34) info.Font = Enum.Font.Gotham info.Text = "Textures, decals, particles and lights are reduced." info.TextWrapped = true info.TextSize = 13 info.TextXAlignment = Enum.TextXAlignment.Left info.TextYAlignment = Enum.TextYAlignment.Top info.TextColor3 = Color3.fromRGB(182, 194, 223) info.ZIndex = 21 info.Parent = panel local statusLabel = Instance.new("TextLabel") statusLabel.BackgroundTransparency = 1 statusLabel.Position = UDim2.fromOffset(14, 82) statusLabel.Size = UDim2.fromOffset(272, 20) statusLabel.Font = Enum.Font.GothamSemibold statusLabel.TextSize = 14 statusLabel.TextXAlignment = Enum.TextXAlignment.Left statusLabel.ZIndex = 21 statusLabel.Parent = panel local toggleButton = Instance.new("TextButton") toggleButton.Position = UDim2.fromOffset(14, 110) toggleButton.Size = UDim2.fromOffset(272, 46) toggleButton.BackgroundColor3 = Color3.fromRGB(60, 153, 97) toggleButton.BorderSizePixel = 0 toggleButton.Font = Enum.Font.GothamBold toggleButton.TextSize = 16 toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) toggleButton.AutoButtonColor = false toggleButton.ZIndex = 21 toggleButton.Parent = panel local toggleCorner = Instance.new("UICorner") toggleCorner.CornerRadius = UDim.new(0, 12) toggleCorner.Parent = toggleButton local toggleStroke = Instance.new("UIStroke") toggleStroke.Thickness = 1.2 toggleStroke.Transparency = 0.2 toggleStroke.Parent = toggleButton local toggleGradient = makeGradient(toggleButton, Color3.fromRGB(64, 186, 110), Color3.fromRGB(45, 143, 89), 20) local function updateButtonState() if antiLagEnabled then statusLabel.Text = "Status: Enabled" statusLabel.TextColor3 = Color3.fromRGB(126, 255, 177) toggleButton.Text = "Disable Anti-Lag" toggleGradient.Color = ColorSequence.new(Color3.fromRGB(233, 95, 95), Color3.fromRGB(196, 65, 65)) toggleStroke.Color = Color3.fromRGB(255, 155, 155) else statusLabel.Text = "Status: Disabled" statusLabel.TextColor3 = Color3.fromRGB(255, 198, 123) toggleButton.Text = "Enable Anti-Lag" toggleGradient.Color = ColorSequence.new(Color3.fromRGB(64, 186, 110), Color3.fromRGB(45, 143, 89)) toggleStroke.Color = Color3.fromRGB(152, 255, 196) end end updateButtonState() addConnection(openButton.MouseButton1Click:Connect(function() panel.Visible = not panel.Visible end)) addConnection(closeBtn.MouseButton1Click:Connect(function() panel.Visible = false end)) addConnection(toggleButton.MouseButton1Click:Connect(function() if antiLagEnabled then disableAntiLag() else enableAntiLag() end updateButtonState() end)) return screenGui end local unloaded = false local function cleanup() if unloaded then return end unloaded = true disableAntiLag() for _, conn in ipairs(runtimeConnections) do disconnectConnection(conn) end runtimeConnections = {} if gui then pcall(function() gui:Destroy() end) gui = nil end end sharedEnv.__UNIVERSAL_ANTILAG_UI_CLEANUP = cleanup gui = createUi() notify("Loaded")