Загрузка данных


local UserInputService = game:GetService("UserInputService")
local Lighting = game:GetService("Lighting")
local Players = game:GetService("Players")
local GuiService = game:GetService("GuiService")

local localPlayer = Players.LocalPlayer
local playerGui = localPlayer:WaitForChild("PlayerGui")
local gameSettings = UserSettings():GetService("UserGameSettings")

local lowFpsMode = false
local originalStates = {} -- Хранилище оригинальных настроек игры
local boostButton = nil -- Ссылка на кнопку (если она будет создана)

-- Функция для безопасного сохранения и изменения свойств
local function changeProperty(obj, property, newValue)
	if not originalStates[obj] then
		originalStates[obj] = {}
	end
	if originalStates[obj][property] == nil then
		originalStates[obj][property] = obj[property]
	end
	obj[property] = newValue
end

-- Функция восстановления оригинальных свойств
local function restoreProperties()
	for obj, properties in pairs(originalStates) do
		if obj and obj.Parent then
			for prop, origValue in pairs(properties) do
				pcall(function() obj[prop] = origValue end)
			end
		end
	end
	table.clear(originalStates)
end

-- Основная функция переключения режима
local function setPotatoMode(enable)
	if lowFpsMode == enable then return end -- Если режим уже в нужном состоянии, ничего не делаем
	lowFpsMode = enable
	
	if lowFpsMode then
		-- 1. Настройки освещения и неба
		changeProperty(Lighting, "ClockTime", 0) -- Полночь для черного неба
		changeProperty(Lighting, "Brightness", 2)
		changeProperty(Lighting, "GlobalShadows", false)
		
		-- Изменение качества рендера ROBLOX
		pcall(function()
			settings().Rendering.QualityLevel = Enum.QualityLevel.Level01
		end)
		
		-- 2. Эффекты и Небосклон
		local function disableEffects(parent)
			for _, effect in ipairs(parent:GetChildren()) do
				if effect:IsA("PostEffect") or effect:IsA("BlurEffect") or effect:IsA("BloomEffect") or 
					effect:IsA("SunRaysEffect") or effect:IsA("ColorCorrectionEffect") or effect:IsA("Atmosphere") or 
					effect:IsA("Clouds") then
					changeProperty(effect, "Enabled", false)
				elseif effect:IsA("Sky") then
					changeProperty(effect, "CelestialBodiesShown", false)
					changeProperty(effect, "SkyboxBk", "rbxassetid://0")
					changeProperty(effect, "SkyboxDn", "rbxassetid://0")
					changeProperty(effect, "SkyboxFt", "rbxassetid://0")
					changeProperty(effect, "SkyboxLf", "rbxassetid://0")
					changeProperty(effect, "SkyboxRt", "rbxassetid://0")
					changeProperty(effect, "SkyboxUp", "rbxassetid://0")
				end
			end
		end
		
		disableEffects(Lighting)
		if workspace.CurrentCamera then disableEffects(workspace.CurrentCamera) end
		
		-- 3. Текстуры, материалы и партиклы в мире
		for _, obj in ipairs(workspace:GetDescendants()) do
			if obj:IsA("BasePart") then
				changeProperty(obj, "Material", Enum.Material.SmoothPlastic)
				changeProperty(obj, "Reflectance", 0)
				changeProperty(obj, "CastShadow", false)
			elseif obj:IsA("Texture") or obj:IsA("Decal") then
				changeProperty(obj, "Transparency", 1)
			elseif obj:IsA("ParticleEmitter") or obj:IsA("Fire") or obj:IsA("Smoke") or obj:IsA("Sparkles") or obj:IsA("Trail") or obj:IsA("Beam") then
				changeProperty(obj, "Enabled", false)
			end
		end
	else
		-- Возвращаем всё как было
		restoreProperties()
		pcall(function()
			settings().Rendering.QualityLevel = Enum.QualityLevel.Automatic
		end)
	end
	
	-- Обновляем визуал кнопки, если она существует
	if boostButton then
		if lowFpsMode then
			boostButton.Text = "FPS: ON"
			boostButton.BackgroundColor3 = Color3.fromRGB(0, 180, 50)
		else
			boostButton.Text = "FPS: OFF"
			boostButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
		end
	end
	
	print("Ultimate Boost Mode: " .. tostring(lowFpsMode))
end

-- === УСЛОВИЕ 1: Проверка уровня графики Roblox ===
local function checkGraphicsQuality()
	-- Если в настройках Roblox стоит самый минимум (QualityLevel1)
	if gameSettings.SavedGraphicsQuality == Enum.SavedQualitySetting.QualityLevel1 then
		setPotatoMode(true)
	else
		-- Если игрок повысил графику обратно, выключаем картофельный режим
		if lowFpsMode and boostButton == nil then 
			setPotatoMode(false)
		end
	end
end

-- Проверяем графику при входе в игру
task.spawn(checkGraphicsQuality)

-- Следим за изменением графики в реальном времени (если игрок изменит её в меню)
gameSettings:GetPropertyChangedSignal("SavedGraphicsQuality"):Connect(checkGraphicsQuality)


-- === УСЛОВИЕ 2: ЧАСТЬ ДЛЯ ПК (Alt + F11) ===
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then return end
	if input.KeyCode == Enum.KeyCode.F11 and (UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) or UserInputService:IsKeyDown(Enum.KeyCode.RightAlt)) then
		setPotatoMode(not lowFpsMode)
	end
end)


-- === УСЛОВИЕ 3: ЧАСТЬ ДЛЯ ТЕЛЕФОНОВ (UI Кнопка) ===
if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled then
	local screenGui = Instance.new("ScreenGui")
	screenGui.Name = "FpsBoostGui"
	screenGui.ResetOnSpawn = false
	
	boostButton = Instance.new("TextButton")
	boostButton.Name = "BoostButton"
	boostButton.Size = UDim2.new(0, 90, 0, 40)
	boostButton.Position = UDim2.new(1, -110, 0, 10) -- Справа вверху экрана
	boostButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
	boostButton.TextColor3 = Color3.fromRGB(255, 255, 255)
	boostButton.TextSize = 14
	boostButton.Font = Enum.Font.SourceSansBold
	boostButton.Text = "FPS: OFF"
	
	local uiCorner = Instance.new("UICorner")
	uiCorner.CornerRadius = UDim.new(0, 8)
	uiCorner.Parent = boostButton
	
	boostButton.Parent = screenGui
	screenGui.Parent = playerGui
	
	-- Кнопка позволяет принудительно переключать режим в любой момент
	boostButton.Activated:Connect(function()
		setPotatoMode(not lowFpsMode)
	end)
	
	-- Сразу обновляем текст кнопки при первом запуске под графику
	if gameSettings.SavedGraphicsQuality == Enum.SavedQualitySetting.QualityLevel1 then
		boostButton.Text = "FPS: ON"
		boostButton.BackgroundColor3 = Color3.fromRGB(0, 180, 50)
	end
end