Fly
Key RequiredUniversal

Fly

Universal Scriptyosinkholohyosinkholoh 17.5K views 127 executesUpdated Dec 7, 2024
Unrated
00
Lua Script•99 lines (3643 chars)
--[[
    WARNING: Heads up! This script has not been verified by ScriptBlox. Use at your own risk!
    Toggle Fly: Press 'F' to start flying / stop flying.
]]

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local flying = false
local speed = 50 -- Speed of flight (adjustable)
local flyHeight = 5 -- Height above the ground when flying

-- BodyVelocity used for flying
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(100000, 100000, 100000) -- Make sure the force is high enough to allow flying
bodyVelocity.Velocity = Vector3.new(0, 0, 0)
bodyVelocity.P = 10000

-- Create a simple UI to show flying status
local flyingLabel = Instance.new("TextLabel")
flyingLabel.Size = UDim2.new(0, 200, 0, 50)
flyingLabel.Position = UDim2.new(0.5, -100, 0.5, -25)
flyingLabel.BackgroundTransparency = 1
flyingLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
flyingLabel.TextScaled = true
flyingLabel.Text = "Press 'F' to Toggle Fly"
flyingLabel.Parent = player.PlayerGui:WaitForChild("ScreenGui")

-- Function to toggle flying on/off
local function toggleFly()
    if flying then
        -- Disable flying: remove the BodyVelocity and return the character to normal state
        bodyVelocity.Parent = nil
        humanoid.PlatformStand = false
        flying = false
        flyingLabel.Text = "Press 'F' to Toggle Fly"
    else
        -- Enable flying: add the BodyVelocity and make the character hover
        bodyVelocity.Parent = humanoidRootPart
        humanoid.PlatformStand = true
        flying = true
        flyingLabel.Text = "Flying..."
    end
end

-- Update fly movement based on key presses
local function updateFlyMovement()
    if flying then
        local camera = workspace.CurrentCamera
        local direction = Vector3.new(0, 0, 0)

        -- Basic WASD movement, plus mouse look
        local forward = (camera.CFrame.LookVector * speed)
        local right = (camera.CFrame.RightVector * speed)
        local up = Vector3.new(0, 1, 0) * flyHeight

        -- Get movement input (WASD keys, etc.)
        if UserInputService:IsKeyDown(Enum.KeyCode.W) then
            direction = direction + forward
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.S) then
            direction = direction - forward
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.A) then
            direction = direction - right
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.D) then
            direction = direction + right
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.Space) then
            direction = direction + up
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
            direction = direction - up
        end

        -- Apply the velocity to the character
        bodyVelocity.Velocity = direction
    end
end

-- Listen for keypress to toggle fly
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.F then
            toggleFly() -- Toggle flying on/off when 'F' is pressed
        end
    end
end)

-- Listen for movement updates while flying
game:GetService("RunService").Heartbeat:Connect(function()
    updateFlyMovement()  -- Update movement direction while flying
end)

Features & Information

Press F to start flying. F again to stop flying. For every game.

Community Comments (4)

travisbat25travisbat25Dec 7, 2024(edited)

don't work

yosinkholohyosinkholohDec 8, 2024(edited)

Never tested

yosinkholohyosinkholohDec 8, 2024(edited)

I got it from Chatgpt

yosinkholohyosinkholohMay 13, 2026

((((MODERATER)))) PLEZ APPROVE; ITS NOT RIVALS BUT ITS SOMETHING TO PROVE IM 7 DAYS OLD ACCOUNT.

More Scripts for Universal Scripts