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


local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = Players.LocalPlayer

-- Настройки функций
local flySpeed = 50
local flying = false
local godActive = false

-- Внутренние переменные управления
local keys = {w = false, s = false, a = false, d = false}
local bv, bg -- Физика полета
local godConnection, jumpConnection, ragdollMonitorConnection -- Потоки слежки
local motor6DBackup = {} -- Бэкап суставов персонажа
local inRagdoll = false
local ragdollStartTime = 0

-- Удаляем старые менюшки, если они были запущены
local oldMultiGui = LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("MultiHackHub")
if oldMultiGui then oldMultiGui:Destroy() end

-- ================= СОЗДАНИЕ КРАСИВОГО ИНТЕРФЕЙСА =================
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "MultiHackHub"
ScreenGui.ResetOnSpawn = false
ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")

-- Главное меню
local MainFrame = Instance.new("Frame")
MainFrame.Size = UDim2.new(0, 180, 0, 210)
MainFrame.Position = UDim2.new(0.05, 0, 0.3, 0)
MainFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 25)
MainFrame.BorderSizePixel = 0
MainFrame.Active = true
MainFrame.Draggable = true
MainFrame.Parent = ScreenGui

local Corner = Instance.new("UICorner")
Corner.CornerRadius = UDim.new(0, 10)
Corner.Parent = MainFrame

-- Шапка
local Header = Instance.new("Frame")
Header.Size = UDim2.new(1, 0, 0, 30)
Header.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
Header.BorderSizePixel = 0
Header.Parent = MainFrame

local HeaderCorner = Instance.new("UICorner")
HeaderCorner.CornerRadius = UDim.new(0, 10)
HeaderCorner.Parent = Header

local Title = Instance.new("TextLabel")
Title.Size = UDim2.new(1, -30, 1, 0)
Title.Position = UDim2.new(0, 10, 0, 0)
Title.BackgroundTransparency = 1
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.Text = "⚡ MULTI-HACK HUB"
Title.Font = Enum.Font.GothamBold
Title.TextSize = 11
Title.TextXAlignment = Enum.TextXAlignment.Left
Title.Parent = Header

-- Кнопка полного закрытия чит-меню [X]
local CloseBtn = Instance.new("TextButton")
CloseBtn.Size = UDim2.new(0, 20, 0, 20)
CloseBtn.Position = UDim2.new(1, -25, 0, 5)
CloseBtn.BackgroundTransparency = 1
CloseBtn.TextColor3 = Color3.fromRGB(150, 150, 150)
CloseBtn.Text = "✕"
CloseBtn.Font = Enum.Font.GothamBold
CloseBtn.TextSize = 14
CloseBtn.Parent = Header


-- ================= РАЗДЕЛ 1: ПОЛЁТ (FLY) =================
local FlyTitle = Instance.new("TextLabel")
FlyTitle.Size = UDim2.new(1, 0, 0, 20)
FlyTitle.Position = UDim2.new(0, 0, 0, 35)
FlyTitle.BackgroundTransparency = 1
FlyTitle.TextColor3 = Color3.fromRGB(150, 150, 150)
FlyTitle.Text = "— FLY HACK —"
FlyTitle.Font = Enum.Font.GothamBold
FlyTitle.TextSize = 9
FlyTitle.Parent = MainFrame

-- Кнопка включения Fly
local FlyToggleBtn = Instance.new("TextButton")
FlyToggleBtn.Size = UDim2.new(1, -20, 0, 25)
FlyToggleBtn.Position = UDim2.new(0, 10, 0, 55)
FlyToggleBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
FlyToggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
FlyToggleBtn.Text = "FLY: OFF"
FlyToggleBtn.Font = Enum.Font.GothamBold
FlyToggleBtn.TextSize = 11
FlyToggleBtn.Parent = MainFrame

local FlyCorner = Instance.new("UICorner")
FlyCorner.CornerRadius = UDim.new(0, 5)
FlyCorner.Parent = FlyToggleBtn

-- Управление скоростью полета
local SpeedDown = Instance.new("TextButton")
SpeedDown.Size = UDim2.new(0, 25, 0, 25)
SpeedDown.Position = UDim2.new(0, 10, 0, 85)
SpeedDown.BackgroundColor3 = Color3.fromRGB(50, 50, 60)
SpeedDown.TextColor3 = Color3.fromRGB(255, 255, 255)
SpeedDown.Text = "-"
SpeedDown.Font = Enum.Font.GothamBold
SpeedDown.TextSize = 14
SpeedDown.Parent = MainFrame

local MinusCorner = Instance.new("UICorner")
MinusCorner.CornerRadius = UDim.new(0, 5)
MinusCorner.Parent = SpeedDown

local SpeedInput = Instance.new("TextBox")
SpeedInput.Size = UDim2.new(0, 110, 0, 25)
SpeedInput.Position = UDim2.new(0, 40, 0, 85)
SpeedInput.BackgroundColor3 = Color3.fromRGB(15, 15, 20)
SpeedInput.TextColor3 = Color3.fromRGB(150, 255, 150)
SpeedInput.Font = Enum.Font.GothamBold
SpeedInput.TextSize = 11
SpeedInput.Text = tostring(flySpeed)
SpeedInput.ClearTextOnFocus = false
SpeedInput.Parent = MainFrame

local InputCorner = Instance.new("UICorner")
InputCorner.CornerRadius = UDim.new(0, 5)
InputCorner.Parent = SpeedInput

local SpeedUp = Instance.new("TextButton")
SpeedUp.Size = UDim2.new(0, 25, 0, 25)
SpeedUp.Position = UDim2.new(1, -35, 0, 85)
SpeedUp.BackgroundColor3 = Color3.fromRGB(50, 50, 60)
SpeedUp.TextColor3 = Color3.fromRGB(255, 255, 255)
SpeedUp.Text = "+"
SpeedUp.Font = Enum.Font.GothamBold
SpeedUp.TextSize = 14
SpeedUp.Parent = MainFrame

local PlusCorner = Instance.new("UICorner")
PlusCorner.CornerRadius = UDim.new(0, 5)
PlusCorner.Parent = SpeedUp


-- ================= РАЗДЕЛ 2: БЕССМЕРТИЕ (GOD MODE) =================
local GodTitle = Instance.new("TextLabel")
GodTitle.Size = UDim2.new(1, 0, 0, 20)
GodTitle.Position = UDim2.new(0, 0, 0, 120)
GodTitle.BackgroundTransparency = 1
GodTitle.TextColor3 = Color3.fromRGB(150, 150, 150)
GodTitle.Text = "— SURVIVAL —"
GodTitle.Font = Enum.Font.GothamBold
GodTitle.TextSize = 9
GodTitle.Parent = MainFrame

-- Кнопка включения God Mode
local GodToggleBtn = Instance.new("TextButton")
GodToggleBtn.Size = UDim2.new(1, -20, 0, 35)
GodToggleBtn.Position = UDim2.new(0, 10, 0, 140)
GodToggleBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
GodToggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
GodToggleBtn.Text = "GODMODE: OFF"
GodToggleBtn.Font = Enum.Font.GothamBold
GodToggleBtn.TextSize = 11
GodToggleBtn.Parent = MainFrame

local GodCorner = Instance.new("UICorner")
GodCorner.CornerRadius = UDim.new(0, 5)
GodCorner.Parent = GodToggleBtn


-- ================= ЛОГИКА ФУНКЦИИ: ПОЛЁТ =================
local function startFly()
	local char = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
	local hrp = char:WaitForChild("HumanoidRootPart")
	local camera = workspace.CurrentCamera
	
	hrp.Velocity = Vector3.new(0, 0, 0)
	
	local humanoid = char:FindFirstChildOfClass("Humanoid")
	if humanoid then humanoid.PlatformStand = true end
	
	bg = Instance.new("BodyGyro")
	bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)
	bg.P = 15000
	bg.cframe = hrp.CFrame
	bg.Parent = hrp
	
	bv = Instance.new("BodyVelocity")
	bv.maxForce = Vector3.new(9e9, 9e9, 9e9)
	bv.velocity = Vector3.new(0, 0, 0)
	bv.Parent = hrp
	
	task.spawn(function()
		while flying and char and hrp and char.Parent do
			RunService.RenderStepped:Wait()
			local camCFrame = camera.CFrame
			local direction = Vector3.new(0, 0, 0)
			
			local activeHumanoid = char:FindFirstChildOfClass("Humanoid")
			if activeHumanoid and not activeHumanoid.PlatformStand then
				activeHumanoid.PlatformStand = true
			end
			
			if keys.w then direction = direction + camCFrame.LookVector end
			if keys.s then direction = direction - camCFrame.LookVector end
			if keys.a then direction = direction - camCFrame.RightVector end
			if keys.d then direction = direction + camCFrame.RightVector end
			
			if direction.Magnitude == 0 and activeHumanoid and activeHumanoid.MoveDirection.Magnitude > 0 then
				local flatLook = (camCFrame.LookVector * Vector3.new(1, 0, 1)).Unit
				local flatRight = (camCFrame.RightVector * Vector3.new(1, 0, 1)).Unit
				local forwardAmount = activeHumanoid.MoveDirection:Dot(flatLook)
				local rightAmount = activeHumanoid.MoveDirection:Dot(flatRight)
				direction = (camCFrame.LookVector * forwardAmount) + (camCFrame.RightVector * rightAmount)
			end
			
			if direction.Magnitude > 0 then
				bv.velocity = direction.Unit * flySpeed
			else
				bv.velocity = Vector3.new(0, 0, 0)
			end
			bg.cframe = camCFrame
		end
	end)
end

local function stopFly()
	local char = LocalPlayer.Character
	if char then
		local humanoid = char:FindFirstChildOfClass("Humanoid")
		if humanoid then humanoid.PlatformStand = false end
	end
	if bv then bv:Destroy() bv = nil end
	if bg then bg:Destroy() bg = nil end
end

local function toggleFly()
	flying = not flying
	if flying then
		FlyToggleBtn.Text = "FLY: ON"
		FlyToggleBtn.BackgroundColor3 = Color3.fromRGB(0, 180, 100)
		startFly()
	else
		FlyToggleBtn.Text = "FLY: OFF"
		FlyToggleBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
		stopFly()
	end
end


-- ================= ЛОГИКА ФУНКЦИИ: БЕССМЕРТИЕ И СМАРТ-РЭГДОЛЛ =================

local function isGrounded(char, hrp)
	if not char or not hrp then return false end
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {char}
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude
	local rayResult = workspace:Raycast(hrp.Position, Vector3.new(0, -4.5, 0), raycastParams)
	return rayResult ~= nil
end

-- Создание бэкапа скелета (Motor6D)
local function backupMotor6D(char)
	motor6DBackup = {}
	for _, desc in pairs(char:GetDescendants()) do
		if desc:IsA("Motor6D") then
			table.insert(motor6DBackup, {
				motor = desc,
				part0 = desc.Part0,
				part1 = desc.Part1,
				c0 = desc.C0,
				c1 = desc.C1,
				parent = desc.Parent
			})
		end
	end
end

-- Определение рэгдолла на основе физического состояния и констрейнтов
local function checkIsRagdolled(char, humanoid)
	if not char or not humanoid then return false end
	
	-- 1. Смена стейтов
	local state = humanoid:GetState()
	if state == Enum.HumanoidStateType.Physics or 
	   state == Enum.HumanoidStateType.Ragdoll or 
	   state == Enum.HumanoidStateType.FallingDown then
		return true
	end
	
	-- 2. Принудительное падение
	if humanoid.PlatformStand == true and not flying then
		return true
	end
	
	-- 3. Наличие рэгдолл-элементов
	for _, obj in pairs(char:GetDescendants()) do
		if obj:IsA("BallSocketConstraint") or obj:IsA("HingeConstraint") then
			return true
		end
	end
	
	return false
end

-- Механизм подъема персонажа
local function fixRagdoll(char, humanoid, hrp)
	if not char or not humanoid or not hrp or not godActive then return end
	
	-- Удаляем рэгдолл связи
	for _, obj in pairs(char:GetDescendants()) do
		if obj:IsA("BallSocketConstraint") or 
		   obj:IsA("HingeConstraint") or 
		   obj:IsA("NoCollisionConstraint") then
			obj:Destroy()
		end
	end
	
	-- Восстанавливаем Motor6D (кости)
	for _, data in pairs(motor6DBackup) do
		if data.motor and data.motor.Parent == nil and data.parent and data.parent.Parent then
			local newMotor = Instance.new("Motor6D")
			newMotor.Name = data.motor.Name
			newMotor.Part0 = data.part0
			newMotor.Part1 = data.part1
			newMotor.C0 = data.c0
			newMotor.C1 = data.c1
			newMotor.Parent = data.parent
		end
	end
	
	-- Мгновенный сброс скоростей и якорение
	hrp.Anchored = true
	hrp.Velocity = Vector3.new(0, 0, 0)
	hrp.RotVelocity = Vector3.new(0, 0, 0)
	
	humanoid.PlatformStand = false
	humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
	
	-- Отключаем коллизию конечностей, чтобы не застрять в текстурах
	for _, part in pairs(char:GetChildren()) do
		if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
			part.CanCollide = false
		end
	end
	
	task.wait(0.03)
	if hrp and hrp.Parent then
		hrp.Anchored = false
	end
	
	inRagdoll = false
	ragdollStartTime = 0
end

local function enableGodMode()
	local char = LocalPlayer.Character
	if not char then return end
	local humanoid = char:FindFirstChildOfClass("Humanoid")
	if not humanoid then return end
	local hrp = char:FindFirstChild("HumanoidRootPart")
	if not hrp then return end

	backupMotor6D(char)

	-- Задаем бесконечное здоровье на оригинальном Humanoid
	humanoid.MaxHealth = math.huge
	humanoid.Health = math.huge
	humanoid.BreakJointsOnDeath = false
	humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
	
	-- Постоянное обновление (бессмертие, бездна, таймер рэгдолла)
	ragdollMonitorConnection = RunService.Heartbeat:Connect(function()
		if not char or not char.Parent or not hrp or not hrp.Parent or not godActive then return end
		
		if humanoid.Health < math.huge then
			humanoid.Health = math.huge
		end
		
		-- Бездна
		if hrp.Position.Y < (workspace.FallenPartsDestroyHeight + 25) then
			hrp.Velocity = Vector3.new(0, 0, 0)
			hrp.CFrame = CFrame.new(hrp.Position.X, 100, hrp.Position.Z)
		end
		
		-- Умное отслеживание времени в рэгдолле
		local currentlyRagdolled = checkIsRagdolled(char, humanoid)
		if currentlyRagdolled then
			if not inRagdoll then
				inRagdoll = true
				ragdollStartTime = tick()
			end
			
			-- ЕСЛИ ПРОЛЕЖАЛ 3 СЕКУНДЫ -> ВСТАЕМ!
			if tick() - ragdollStartTime >= 3 then
				fixRagdoll(char, humanoid, hrp)
			end
		else
			if inRagdoll then
				inRagdoll = false
				ragdollStartTime = 0
			end
		end
	end)
	
	-- ПРЫЖОК: Подъем по прыжку или физический буст
	local lastJumpTime = 0
	jumpConnection = UserInputService.JumpRequest:Connect(function()
		if not godActive or flying or not humanoid or not hrp then return end
		
		-- ЕСЛИ НАХОДИМСЯ В РЭГДОЛЛЕ -> ПРОБЕЛ МГНОВЕННО ПОДНИМАЕТ!
		if inRagdoll or checkIsRagdolled(char, humanoid) then
			fixRagdoll(char, humanoid, hrp)
			return
		end
		
		-- Обычный прыжок
		local currentTime = tick()
		if currentTime - lastJumpTime < 0.3 then return end
		if not isGrounded(char, hrp) then return end
		
		lastJumpTime = currentTime
		
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
		hrp.Velocity = Vector3.new(hrp.Velocity.X, 50, hrp.Velocity.Z)
		
		task.spawn(function()
			for i = 1, 3 do
				task.wait(0.02)
				if hrp and hrp.Parent then
					hrp.AssemblyLinearVelocity = Vector3.new(
						hrp.AssemblyLinearVelocity.X, 
						50, 
						hrp.AssemblyLinearVelocity.Z
					)
				end
			end
		end)
	end)
	
	-- На всякий случай блокируем вызов Died на клиенте
	godConnection = humanoid.Died:Connect(function()
		if godActive then humanoid.Health = math.huge end
	end)
	
	print("[ANTI-RAGDOLL] GodMode успешно запущен!")
end

local function disableGodMode()
	-- Полное отключение всех соединений
	if godConnection then godConnection:Disconnect() godConnection = nil end
	if jumpConnection then jumpConnection:Disconnect() jumpConnection = nil end
	if ragdollMonitorConnection then ragdollMonitorConnection:Disconnect() ragdollMonitorConnection = nil end
	
	inRagdoll = false
	ragdollStartTime = 0
	
	local char = LocalPlayer.Character
	if not char then return end
	local humanoid = char:FindFirstChildOfClass("Humanoid")
	
	if humanoid then
		-- Возвращаем всё к заводским настройкам
		humanoid.MaxHealth = 100
		humanoid.Health = 100
		humanoid.BreakJointsOnDeath = true
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
		humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
	end
	
	motor6DBackup = {}
	print("[ANTI-RAGDOLL] GodMode полностью отключен.")
end

local function toggleGodMode()
	godActive = not godActive
	if godActive then
		GodToggleBtn.Text = "GODMODE: ACTIVE"
		GodToggleBtn.BackgroundColor3 = Color3.fromRGB(0, 180, 100)
		enableGodMode()
	else
		GodToggleBtn.Text = "GODMODE: OFF"
		GodToggleBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
		disableGodMode()
	end
end


-- ================= УПРАВЛЕНИЕ И КНОПКИ =================

SpeedInput.FocusLost:Connect(function()
	local enteredValue = tonumber(SpeedInput.Text)
	if enteredValue then
		flySpeed = enteredValue
	else
		SpeedInput.Text = tostring(flySpeed)
	end
end)

SpeedDown.Activated:Connect(function()
	flySpeed = math.max(10, flySpeed - 10)
	SpeedInput.Text = tostring(flySpeed)
end)

SpeedUp.Activated:Connect(function()
	flySpeed = flySpeed + 10
	SpeedInput.Text = tostring(flySpeed)
end)

FlyToggleBtn.Activated:Connect(toggleFly)
GodToggleBtn.Activated:Connect(toggleGodMode)

-- Кнопка [✕] Закрыть меню полностью
CloseBtn.Activated:Connect(function()
	flying = false
	stopFly()
	if godActive then
		godActive = false
		disableGodMode()
	end
	ScreenGui:Destroy()
end)

-- Считывание клавиатуры
UserInputService.InputBegan:Connect(function(input, processed)
	if processed then return end
	if input.KeyCode == Enum.KeyCode.F then toggleFly() end
	if input.KeyCode == Enum.KeyCode.W then keys.w = true end
	if input.KeyCode == Enum.KeyCode.S then keys.s = true end
	if input.KeyCode == Enum.KeyCode.A then keys.a = true end
	if input.KeyCode == Enum.KeyCode.D then keys.d = true end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W then keys.w = false end
	if input.KeyCode == Enum.KeyCode.S then keys.s = false end
	if input.KeyCode == Enum.KeyCode.A then keys.a = false end
	if input.KeyCode == Enum.KeyCode.D then keys.d = false end
end)


-- ================= АВТО-СБРОС ПРИ СМЕРТИ/СПАВНЕ =================

LocalPlayer.CharacterAdded:Connect(function()
	godActive = false
	GodToggleBtn.Text = "GODMODE: OFF"
	GodToggleBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
	
	if godConnection then godConnection:Disconnect() godConnection = nil end
	if jumpConnection then jumpConnection:Disconnect() jumpConnection = nil end
	if ragdollMonitorConnection then ragdollMonitorConnection:Disconnect() ragdollMonitorConnection = nil end
	
	inRagdoll = false
	ragdollStartTime = 0
	motor6DBackup = {}
	
	if flying then
		task.wait(1)
		startFly()
	end
end)

print("[MULTI HUB] Запущено! GodMode без замены гуманоида работает.")