-- made by kason
-- Press "F" to toggle flight
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local flying = false
local speed = 50 -- Adjust this to go faster or slower
local bv -- Our velocity object
UIS.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.F then
flying = not flying
local character = player.Character
local hrp = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChild("Humanoid")
if flying then
-- Create the force that keeps us in the air
bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e6, 1e6, 1e6)
bv.Velocity = Vector3.new(0, 0, 0)
bv.Parent = hrp
humanoid.PlatformStand = true -- Stops the "falling" animation
else
-- Clean up when landing
if bv then bv:Destroy() end
humanoid.PlatformStand = false
end
end
end)
-- This updates every frame to move us where we look
RunService.RenderStepped:Connect(function()
if flying and bv and player.Character then
local hrp = player.Character:FindFirstChild("HumanoidRootPart")
if hrp then
-- Moves the character toward where the camera is pointing
bv.Velocity = camera.CFrame.LookVector * speed
end
end
end)
Comments
No comments yet
Be the first to share your thoughts!