
KeylessUniversal

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local flying = false
local speed = 60
local bodyVelocity
local bodyGyro
local flyConnection
local gui = Instance.new("ScreenGui")
gui.Name = "FlyGui"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")
local button = Instance.new("TextButton")
button.Size = UDim2.new(0, 140, 0, 50)
button.Position = UDim2.new(0, 20, 0.5, -25)
button.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
button.TextColor3 = Color3.fromRGB(255, 255, 255)
button.TextSize = 20
button.Text = "Fly: OFF"
button.Active = true
button.Parent = gui
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 10)
corner.Parent = button
local dragging = false
local dragStart
local startPosition
button.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1
or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPosition = button.Position
end
end)
UserInputService.InputChanged:Connect(function(input)
if not dragging then return end
if input.UserInputType == Enum.UserInputType.MouseMovement
or input.UserInputType == Enum.UserInputType.Touch then
local delta = input.Position - dragStart
button.Position = UDim2.new(
startPosition.X.Scale,
startPosition.X.Offset + delta.X,
startPosition.Y.Scale,
startPosition.Y.Offset + delta.Y
)
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1
or input.UserInputType == Enum.UserInputType.Touch then
dragging = false
end
end)
local function stopFlying()
flying = false
button.Text = "Fly: OFF"
button.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
if flyConnection then
flyConnection:Disconnect()
flyConnection = nil
end
if bodyVelocity then
bodyVelocity:Destroy()
bodyVelocity = nil
end
if bodyGyro then
bodyGyro:Destroy()
bodyGyro = nil
end
end
local function startFlying()
local character = player.Character
if not character then return end
local root = character:FindFirstChild("HumanoidRootPart")
if not root then return end
flying = true
button.Text = "Fly: ON"
button.BackgroundColor3 = Color3.fromRGB(0, 170, 85)
bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.Parent = root
bodyGyro = Instance.new("BodyGyro")
bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bodyGyro.P = 9000
bodyGyro.Parent = root
flyConnection = RunService.RenderStepped:Connect(function()
if not flying or not root.Parent then
stopFlying()
return
end
local camera = workspace.CurrentCamera
local direction = Vector3.zero
if UserInputService:IsKeyDown(Enum.KeyCode.W) then
direction += camera.CFrame.LookVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.S) then
direction -= camera.CFrame.LookVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.A) then
direction -= camera.CFrame.RightVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.D) then
direction += camera.CFrame.RightVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.Space) then
direction += Vector3.yAxis
end
if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then
direction -= Vector3.yAxis
end
if direction.Magnitude > 0 then
direction = direction.Unit * speed
end
bodyVelocity.Velocity = direction
bodyGyro.CFrame = camera.CFrame
end)
end
local function toggleFly()
if flying then
stopFlying()
else
startFlying()
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
toggleFly()
end
end)
button.MouseButton1Click:Connect(toggleFly)
player.CharacterAdded:Connect(function()
stopFlying()
end)No comments yet for this script.



