Universal Fly Script
Key RequiredUniversal

Universal Fly Script

Universal Scriptdinasdinas 9.6K views 79 executesUpdated Aug 7, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•141 lines (4917 chars)
local Players     = game:GetService("Players")
local RunService  = game:GetService("RunService")
local UserInput   = game:GetService("UserInputService")

local player    = Players.LocalPlayer
local char      = player.Character or player.CharacterAdded:Wait()
local hrp       = char:WaitForChild("HumanoidRootPart")
local humanoid  = char:WaitForChild("Humanoid")

local flying    = false
local speed     = 60
local control   = {F=0,B=0,L=0,R=0,U=0,D=0}

local bv, bg

local function startFly()
    if flying then return end
    flying = true
    humanoid.PlatformStand = true
    bv = Instance.new("BodyVelocity", hrp)
    bv.MaxForce = Vector3.new(1e5,1e5,1e5)
    bv.Velocity = Vector3.new()
    bg = Instance.new("BodyGyro", hrp)
    bg.MaxTorque = Vector3.new(1e5,1e5,1e5)
    bg.P = 1e4
    bg.CFrame = workspace.CurrentCamera.CFrame
end

local function stopFly()
    if not flying then return end
    flying = false
    humanoid.PlatformStand = false
    if bv then bv:Destroy() end
    if bg then bg:Destroy() end
end

UserInput.InputBegan:Connect(function(inp, gp)
    if gp then return end
    local k = inp.KeyCode
    if k == Enum.KeyCode.F then startFly()
    elseif k == Enum.KeyCode.Q then stopFly()
    elseif k == Enum.KeyCode.W then control.F = 1
    elseif k == Enum.KeyCode.S then control.B = 1
    elseif k == Enum.KeyCode.A then control.L = 1
    elseif k == Enum.KeyCode.D then control.R = 1
    elseif k == Enum.KeyCode.Space then control.U = 1
    elseif k == Enum.KeyCode.LeftControl then control.D = 1
    end
end)

UserInput.InputEnded:Connect(function(inp, gp)
    if gp then return end
    local k = inp.KeyCode
    if k == Enum.KeyCode.W then control.F = 0
    elseif k == Enum.KeyCode.S then control.B = 0
    elseif k == Enum.KeyCode.A then control.L = 0
    elseif k == Enum.KeyCode.D then control.R = 0
    elseif k == Enum.KeyCode.Space then control.U = 0
    elseif k == Enum.KeyCode.LeftControl then control.D = 0
    end
end)

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "FlyGui"
screenGui.ResetOnSpawn = false
screenGui.Parent = player:WaitForChild("PlayerGui")

local frame = Instance.new("Frame", screenGui)
frame.Size = UDim2.new(0,200,0,400)
frame.Position = UDim2.new(0,20,1,-420)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.new(0,0,0)

local function makeBtn(text, pos)
    local b = Instance.new("TextButton", frame)
    b.Size = UDim2.new(0,60,0,60)
    b.Position = pos
    b.Text = text
    b.TextColor3 = Color3.new(1,1,1)
    b.BackgroundColor3 = Color3.fromRGB(40,40,40)
    return b
end

local btnFly  = makeBtn("Fly",  UDim2.new(0,0,  0,0))
local btnLand = makeBtn("Land", UDim2.new(0,70, 0,0))
local btnW    = makeBtn("W",    UDim2.new(0,70, 0,70))
local btnA    = makeBtn("A",    UDim2.new(0,0,  0,140))
local btnS    = makeBtn("S",    UDim2.new(0,70, 0,140))
local btnD    = makeBtn("D",    UDim2.new(0,140,0,140))
local btnUp   = makeBtn("Up",   UDim2.new(0,70, 0,210))
local btnDn   = makeBtn("Dn",   UDim2.new(0,70, 0,280))

local btnInc  = makeBtn("+",    UDim2.new(0,0,  0,350))
local btnDec  = makeBtn("-",    UDim2.new(0,70, 0,350))

local lblSpeed = Instance.new("TextLabel", frame)
lblSpeed.Size = UDim2.new(0,60,0,60)
lblSpeed.Position = UDim2.new(0,140,0,350)
lblSpeed.BackgroundTransparency = 1
lblSpeed.TextColor3 = Color3.new(1,1,1)
lblSpeed.Text = tostring(speed)

btnFly.MouseButton1Down:Connect(startFly)
btnLand.MouseButton1Down:Connect(stopFly)

btnW.MouseButton1Down:Connect(function() control.F=1 end)
btnW.MouseButton1Up:Connect(  function() control.F=0 end)
btnS.MouseButton1Down:Connect(function() control.B=1 end)
btnS.MouseButton1Up:Connect(  function() control.B=0 end)
btnA.MouseButton1Down:Connect(function() control.L=1 end)
btnA.MouseButton1Up:Connect(  function() control.L=0 end)
btnD.MouseButton1Down:Connect(function() control.R=1 end)
btnD.MouseButton1Up:Connect(  function() control.R=0 end)
btnUp.MouseButton1Down:Connect(function() control.U=1 end)
btnUp.MouseButton1Up:Connect(  function() control.U=0 end)
btnDn.MouseButton1Down:Connect(function() control.D=1 end)
btnDn.MouseButton1Up:Connect(  function() control.D=0 end)

btnInc.MouseButton1Down:Connect(function()
    speed = speed + 10
    lblSpeed.Text = tostring(speed)
end)
btnDec.MouseButton1Down:Connect(function()
    speed = math.max(10, speed - 10)
    lblSpeed.Text = tostring(speed)
end)

RunService.RenderStepped:Connect(function()
    if flying and bv and bg then
        bg.CFrame = workspace.CurrentCamera.CFrame
        local cam = workspace.CurrentCamera.CFrame
        local dir = (cam.LookVector * (control.F - control.B)
                   + cam.RightVector * (control.R - control.L)
                   + Vector3.new(0,1,0) * (control.U - control.D))
        if dir.Magnitude > 0 then
            bv.Velocity = dir.Unit * speed
        else
            bv.Velocity = Vector3.new()
        end
    end
end)

Features & Information

Universal Fly Script By Dinas Works in mobile and pc

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts