Toggle Flying
<all_urls>
local flying = false
local speed = 50 -- Speed of flight
local flyingHeight = 50 -- How high the player flies
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local bodyVelocity
-- Toggle flight
local function toggleFlight()
if flying then
-- Stop flying
flying = false
bodyVelocity:Destroy()
humanoid.PlatformStand = false
else
-- Start flying
flying = true
humanoid.PlatformStand = true
-- Create a body velocity to simulate flight
bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(500000, 500000, 500000) -- Large force to allow flight
bodyVelocity.Velocity = Vector3.new(0, speed, 0) -- Going upward
bodyVelocity.Parent = rootPart
end
end
-- Listen for button press (F key)
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
toggleFlight()
end
end)
-- Keep the player in the air when flying
game:GetService("RunService").Heartbeat:Connect(function()
if flying then
-- Continuously apply upward velocity to maintain flight
bodyVelocity.Velocity = Vector3.new(0, speed, 0)
end
end)
Install requires the InjectJS Chrome extension. Scripts run only on sites matching the pattern above. Review code before installing any community script.