-- Создаем GUI кнопку на экране
local ScreenGui = Instance.new("ScreenGui")
local FlyButton = Instance.new("TextButton")
ScreenGui.Name = "FlyButtonGui"
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
FlyButton.Name = "FlyButton"
FlyButton.Parent = ScreenGui
FlyButton.Size = UDim2.new(0, 100, 0, 50)
FlyButton.Position = UDim2.new(0.5, -50, 0.9, -25)
FlyButton.Text = "Fly"
FlyButton.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
FlyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
FlyButton.Font = Enum.Font.SourceSans
FlyButton.TextSize = 24
-- Функция для начала/остановки полета
local function toggleFly()
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
if humanoid:GetState() == Enum.HumanoidStateType.Physics then
humanoid:ChangeState(Enum.HumanoidStateType.RunningNoPhysics)
humanoid.PlatformStand = false
else
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
humanoid.PlatformStand = true
character.PrimaryPart.Velocity = Vector3.new(0, 50, 0) -- Скорость полета
end
end
end
-- Привязка функции к клавише Q
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.Q then
toggleFly()
end
end
end)
-- Привязка функции к кнопке на экране
FlyButton.MouseButton1Click:Connect(function()
toggleFly()
end)