
KeylessUniversal

-- Made By l4qic
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local flying = false
local speed = 100 -- adjust
local acceleration = 8
local currentVelocity = Vector3.new(0, 0, 0)
local bodyVelocity
local bodyGyro
local function startFlying()
if flying then return end
flying = true
humanoid.PlatformStand = true
bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(1e5, 1e5, 1e5)
bodyVelocity.Velocity = Vector3.new(0, 0, 0)
bodyVelocity.Parent = character:FindFirstChild("HumanoidRootPart")
bodyGyro = Instance.new("BodyGyro")
bodyGyro.MaxTorque = Vector3.new(1e5, 1e5, 1e5)
bodyGyro.P = 10000
bodyGyro.D = 500
bodyGyro.Parent = character:FindFirstChild("HumanoidRootPart")
end
local function stopFlying()
if not flying then return end
flying = false
if bodyVelocity then bodyVelocity:Destroy() end
if bodyGyro then bodyGyro:Destroy() end
humanoid.PlatformStand = false
currentVelocity = Vector3.new(0, 0, 0)
end
local function updateFly(dt)
if not flying or not bodyVelocity or not bodyGyro then return end
local moveDirection = Vector3.new(0, 0, 0)
if UIS:IsKeyDown(Enum.KeyCode.W) then moveDirection = moveDirection + camera.CFrame.LookVector end
if UIS:IsKeyDown(Enum.KeyCode.S) then moveDirection = moveDirection - camera.CFrame.LookVector end
if UIS:IsKeyDown(Enum.KeyCode.A) then moveDirection = moveDirection - camera.CFrame.RightVector end
if UIS:IsKeyDown(Enum.KeyCode.D) then moveDirection = moveDirection + camera.CFrame.RightVector end
if UIS:IsKeyDown(Enum.KeyCode.Space) then moveDirection = moveDirection + Vector3.new(0, 1, 0) end
if UIS:IsKeyDown(Enum.KeyCode.LeftControl) then moveDirection = moveDirection - Vector3.new(0, 1, 0) end
-- normalize and apply acceleration
if moveDirection.Magnitude > 0 then
moveDirection = moveDirection.Unit
currentVelocity = currentVelocity:Lerp(moveDirection * speed, acceleration * dt)
else
currentVelocity = currentVelocity:Lerp(Vector3.new(0, 0, 0), 0.1 * dt * 60)
end
bodyVelocity.Velocity = currentVelocity
-- smoothly align character to camera direction
local rootPart = character:FindFirstChild("HumanoidRootPart")
if rootPart then
bodyGyro.CFrame = CFrame.lookAt(rootPart.Position, rootPart.Position + camera.CFrame.LookVector)
end
end
UIS.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
if flying then
stopFlying()
else
startFlying()
end
end
end)
-- main loop
RunService.RenderStepped:Connect(function(dt)
updateFly(dt)
end)
-- cleanup on character respawn
character = newChar
humanoid = newChar:WaitForChild("Humanoid")
if flying then
stopFlying()
end
end)No comments yet for this script.



