Fly v5 AND VEHICLE FLY Free Source
Key RequiredUniversal

Fly v5 AND VEHICLE FLY Free Source

Universal ScriptEricBerpaEricBerpa 698 views 6.2K executesUpdated Oct 1, 2026
5.0/ 5(3 votes)
30100% Positive
Lua Script•551 lines (19607 chars)
-- Fly Script + Vehicle Fly + Noclip + GUI (executor version)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

-- ============ STATE ============
local flying = false
local speed = 60
local bodyVelocity, bodyGyro, flyConnection

local noclipEnabled = false
local noclipConnection

local vehicleFlyEnabled = false
local vehicleFlyActive = false
local vehicleBodyVelocity, vehicleBodyGyro
local vehicleRoot
local vehicleRenderConnection
local vehicleMonitorConnection
local savedCameraSubject
local savedCameraType

local ui = {}
local connections = {}

-- ============ FORWARD DECLARATIONS ============
local updateFlyButton
local updateNoclipButton
local updateVehicleFlyButton

local function track(conn)
    connections[#connections + 1] = conn
    return conn
end
local function disconnectAll()
    for _, c in ipairs(connections) do
        pcall(function() c:Disconnect() end)
    end
    connections = {}
end

-- ============ ANTI-RAGDOLL ============
local RAGDOLL_STATES = {
    Enum.HumanoidStateType.FallingDown,
    Enum.HumanoidStateType.Ragdoll,
    Enum.HumanoidStateType.Physics,
}
local function disableRagdollStates(h)
    for _, s in ipairs(RAGDOLL_STATES) do
        pcall(function() h:SetStateEnabled(s, false) end)
    end
end
local function restoreRagdollStates(h)
    for _, s in ipairs(RAGDOLL_STATES) do
        pcall(function() h:SetStateEnabled(s, true) end)
    end
end

-- ============ CHARACTER FLY ============
local function startFly()
    local char = player.Character
    if not char or flying then return end
    local hrp = char:FindFirstChild("HumanoidRootPart")
    local humanoid = char:FindFirstChildOfClass("Humanoid")
    if not hrp or not humanoid then return end
    if humanoid.Sit then return end

    flying = true
    disableRagdollStates(humanoid)
    humanoid.PlatformStand = true

    bodyVelocity = Instance.new("BodyVelocity")
    bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    bodyVelocity.Velocity = Vector3.zero
    bodyVelocity.Parent = hrp

    bodyGyro = Instance.new("BodyGyro")
    bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
    bodyGyro.P = 10000
    bodyGyro.D = 500
    bodyGyro.CFrame = hrp.CFrame
    bodyGyro.Parent = hrp

    flyConnection = RunService.RenderStepped:Connect(function()
        if not flying or not bodyVelocity or not bodyGyro then return end
        local dir = Vector3.zero
        local camCF = camera.CFrame
        if UserInputService:IsKeyDown(Enum.KeyCode.W) then dir += camCF.LookVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.S) then dir -= camCF.LookVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.A) then dir -= camCF.RightVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.D) then dir += camCF.RightVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.Space) then dir += Vector3.yAxis end
        if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then dir -= Vector3.yAxis end
        bodyVelocity.Velocity = dir.Magnitude > 0 and (dir.Unit * speed) or Vector3.zero
        bodyGyro.CFrame = camCF
    end)
end

local function stopFly()
    flying = false
    if flyConnection then flyConnection:Disconnect() flyConnection = nil end
    if bodyVelocity then bodyVelocity:Destroy() bodyVelocity = nil end
    if bodyGyro then bodyGyro:Destroy() bodyGyro = nil end

    local char = player.Character
    if char then
        local humanoid = char:FindFirstChildOfClass("Humanoid")
        if humanoid then
            humanoid.PlatformStand = false
            humanoid.Sit = false
            pcall(function() humanoid:ChangeState(Enum.HumanoidStateType.GettingUp) end)
            pcall(function() humanoid:ChangeState(Enum.HumanoidStateType.Running) end)
            task.delay(0.25, function()
                if humanoid and humanoid.Parent then
                    restoreRagdollStates(humanoid)
                end
            end)
        end
    end
end

-- ============ NOCLIP ============
local function startNoclip()
    if noclipEnabled then return end
    noclipEnabled = true
    noclipConnection = RunService.Stepped:Connect(function()
        local char = player.Character
        if not char then return end
        for _, part in ipairs(char:GetDescendants()) do
            if part:IsA("BasePart") and part.CanCollide then
                part.CanCollide = false
            end
        end
    end)
end
local function stopNoclip()
    noclipEnabled = false
    if noclipConnection then noclipConnection:Disconnect() noclipConnection = nil end
end

-- ============ VEHICLE FLY ============
local function getSeatAndRoot()
    local char = player.Character
    if not char then return nil, nil end
    local humanoid = char:FindFirstChildOfClass("Humanoid")
    if not humanoid or not humanoid.Sit then return nil, nil end
    local seat = humanoid.SeatPart
    if not seat then return nil, nil end
    local model = seat:FindFirstAncestorOfClass("Model")
    local root = (model and model.PrimaryPart) or seat
    return seat, root
end

local function startVehicleFly()
    if vehicleFlyActive then return end
    local seat, root = getSeatAndRoot()
    if not seat or not root then return end
    vehicleRoot = root
    vehicleFlyActive = true

    if flying then stopFly() end

    vehicleBodyVelocity = Instance.new("BodyVelocity")
    vehicleBodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    vehicleBodyVelocity.Velocity = Vector3.zero
    vehicleBodyVelocity.Parent = vehicleRoot

    vehicleBodyGyro = Instance.new("BodyGyro")
    vehicleBodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
    vehicleBodyGyro.P = 10000
    vehicleBodyGyro.D = 500
    vehicleBodyGyro.CFrame = vehicleRoot.CFrame
    vehicleBodyGyro.Parent = vehicleRoot

    -- ----- SIMPLE CAMERA FIX -----
    -- Just retarget the camera to the vehicle chassis. The default camera
    -- script handles smoothing itself; no Scriptable mode, no fighting.
    savedCameraSubject = camera.CameraSubject
    savedCameraType = camera.CameraType
    camera.CameraType = Enum.CameraType.Custom
    camera.CameraSubject = vehicleRoot

    local yaw = 0
    local lastUpdate = 0

    vehicleRenderConnection = RunService.RenderStepped:Connect(function(dt)
        if not vehicleFlyActive or not vehicleRoot or not vehicleRoot.Parent then return end

        -- Re-assert camera subject in case the engine resets it while seated
        if camera.CameraSubject ~= vehicleRoot then
            camera.CameraSubject = vehicleRoot
        end

        -- Yaw from camera so movement is camera-relative
        local look = camera.CFrame.LookVector
        yaw = math.atan2(-look.X, -look.Z)

        local dir = Vector3.zero
        local camCF = camera.CFrame
        if UserInputService:IsKeyDown(Enum.KeyCode.W) then dir += camCF.LookVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.S) then dir -= camCF.LookVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.A) then dir -= camCF.RightVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.D) then dir += camCF.RightVector end
        if UserInputService:IsKeyDown(Enum.KeyCode.Space) then dir += Vector3.yAxis end
        if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then dir -= Vector3.yAxis end

        vehicleBodyVelocity.Velocity = dir.Magnitude > 0 and (dir.Unit * speed) or Vector3.zero
        -- Flat yaw-only orientation so the vehicle doesn't tumble
        vehicleBodyGyro.CFrame = CFrame.new(vehicleRoot.Position) * CFrame.Angles(0, yaw, 0)
    end)
end

local function stopVehicleFly()
    if not vehicleFlyActive then
        -- Still restore camera in case something got left over
        if savedCameraSubject then
            camera.CameraSubject = savedCameraSubject
            savedCameraSubject = nil
        end
        return
    end
    vehicleFlyActive = false

    if vehicleRenderConnection then vehicleRenderConnection:Disconnect() vehicleRenderConnection = nil end
    if vehicleBodyVelocity then vehicleBodyVelocity:Destroy() vehicleBodyVelocity = nil end
    if vehicleBodyGyro then vehicleBodyGyro:Destroy() vehicleBodyGyro = nil end
    vehicleRoot = nil

    -- Restore camera
    local char = player.Character
    local humanoid = char and char:FindFirstChildOfClass("Humanoid")
    camera.CameraType = savedCameraType or Enum.CameraType.Custom
    camera.CameraSubject = humanoid or savedCameraSubject
    savedCameraSubject = nil
    savedCameraType = nil
end

local function refreshVehicleMonitor()
    if vehicleMonitorConnection then
        vehicleMonitorConnection:Disconnect()
        vehicleMonitorConnection = nil
    end
    if not vehicleFlyEnabled then
        if vehicleFlyActive then stopVehicleFly() end
        return
    end
    vehicleMonitorConnection = RunService.Heartbeat:Connect(function()
        local _, root = getSeatAndRoot()
        if root then
            if not vehicleFlyActive then startVehicleFly() end
        else
            if vehicleFlyActive then stopVehicleFly() end
        end
    end)
end

local function toggleVehicleFly()
    vehicleFlyEnabled = not vehicleFlyEnabled
    refreshVehicleMonitor()
    if updateVehicleFlyButton then updateVehicleFlyButton() end
end

-- ============ UI HELPERS (assign to forward-declared locals) ============
updateFlyButton = function()
    if not ui.flyBtn then return end
    if flying then
        ui.flyBtn.Text = "Fly: ON  [E]"
        ui.flyBtn.BackgroundColor3 = Color3.fromRGB(0, 150, 80)
    else
        ui.flyBtn.Text = "Fly: OFF  [E]"
        ui.flyBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    end
end

updateNoclipButton = function()
    if not ui.noclipBtn then return end
    if noclipEnabled then
        ui.noclipBtn.Text = "Noclip: ON"
        ui.noclipBtn.BackgroundColor3 = Color3.fromRGB(0, 150, 80)
    else
        ui.noclipBtn.Text = "Noclip: OFF"
        ui.noclipBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    end
end

updateVehicleFlyButton = function()
    if not ui.vehicleBtn then return end
    if vehicleFlyEnabled then
        ui.vehicleBtn.Text = "Vehicle Fly: ON  [V]"
        ui.vehicleBtn.BackgroundColor3 = Color3.fromRGB(0, 150, 80)
    else
        ui.vehicleBtn.Text = "Vehicle Fly: OFF  [V]"
        ui.vehicleBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    end
end

local function toggleFly()
    if flying then stopFly() else startFly() end
    updateFlyButton()
end
local function toggleNoclip()
    if noclipEnabled then stopNoclip() else startNoclip() end
    updateNoclipButton()
end

-- ============ DRAGGABLE ============
local function makeDraggable(frame, dragBar)
    local dragging, dragStart, startPos
    track(dragBar.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1
            or input.UserInputType == Enum.UserInputType.Touch then
            dragging = true
            dragStart = input.Position
            startPos = frame.Position
            track(input.Changed:Connect(function()
                if input.UserInputState == Enum.UserInputState.End then
                    dragging = false
                end
            end))
        end
    end))
    track(UserInputService.InputChanged:Connect(function(input)
        if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement
            or input.UserInputType == Enum.UserInputType.Touch) then
            local delta = input.Position - dragStart
            frame.Position = UDim2.new(
                startPos.X.Scale, startPos.X.Offset + delta.X,
                startPos.Y.Scale, startPos.Y.Offset + delta.Y
            )
        end
    end))
end

-- ============ GUI ============
local function buildGui()
    local gui = Instance.new("ScreenGui")
    gui.Name = "FlyGui"
    gui.ResetOnSpawn = false
    gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
    gui.Parent = player:WaitForChild("PlayerGui")
    ui.gui = gui

    local frame = Instance.new("Frame")
    frame.Size = UDim2.new(0, 240, 0, 198)
    frame.Position = UDim2.new(0.5, -120, 0.5, -99)
    frame.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
    frame.BorderSizePixel = 0
    frame.Active = true
    frame.Parent = gui

    local corner = Instance.new("UICorner")
    corner.CornerRadius = UDim.new(0, 8)
    corner.Parent = frame

    -- title bar
    local titleBar = Instance.new("Frame")
    titleBar.Size = UDim2.new(1, 0, 0, 28)
    titleBar.BackgroundColor3 = Color3.fromRGB(50, 50, 58)
    titleBar.BorderSizePixel = 0
    titleBar.Parent = frame

    local titleCorner = Instance.new("UICorner")
    titleCorner.CornerRadius = UDim.new(0, 8)
    titleCorner.Parent = titleBar

    local title = Instance.new("TextLabel")
    title.Size = UDim2.new(1, -40, 1, 0)
    title.Position = UDim2.new(0, 10, 0, 0)
    title.BackgroundTransparency = 1
    title.Text = "Fly Script"
    title.TextColor3 = Color3.fromRGB(240, 240, 240)
    title.Font = Enum.Font.GothamBold
    title.TextSize = 14
    title.TextXAlignment = Enum.TextXAlignment.Left
    title.Parent = titleBar

    local closeBtn = Instance.new("TextButton")
    closeBtn.Size = UDim2.new(0, 22, 0, 22)
    closeBtn.Position = UDim2.new(1, -26, 0, 3)
    closeBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    closeBtn.BorderSizePixel = 0
    closeBtn.Text = "X"
    closeBtn.TextColor3 = Color3.fromRGB(240, 240, 240)
    closeBtn.Font = Enum.Font.GothamBold
    closeBtn.TextSize = 13
    closeBtn.Parent = titleBar
    ui.closeBtn = closeBtn
    local closeCorner = Instance.new("UICorner")
    closeCorner.CornerRadius = UDim.new(0, 6)
    closeCorner.Parent = closeBtn

    -- fly
    local flyBtn = Instance.new("TextButton")
    flyBtn.Size = UDim2.new(1, -20, 0, 34)
    flyBtn.Position = UDim2.new(0, 10, 0, 36)
    flyBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    flyBtn.BorderSizePixel = 0
    flyBtn.Text = "Fly: OFF  [E]"
    flyBtn.TextColor3 = Color3.fromRGB(240, 240, 240)
    flyBtn.Font = Enum.Font.GothamBold
    flyBtn.TextSize = 14
    flyBtn.Parent = frame
    ui.flyBtn = flyBtn
    local flyCorner = Instance.new("UICorner")
    flyCorner.CornerRadius = UDim.new(0, 6)
    flyCorner.Parent = flyBtn

    -- noclip
    local noclipBtn = Instance.new("TextButton")
    noclipBtn.Size = UDim2.new(1, -20, 0, 34)
    noclipBtn.Position = UDim2.new(0, 10, 0, 76)
    noclipBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    noclipBtn.BorderSizePixel = 0
    noclipBtn.Text = "Noclip: OFF"
    noclipBtn.TextColor3 = Color3.fromRGB(240, 240, 240)
    noclipBtn.Font = Enum.Font.GothamBold
    noclipBtn.TextSize = 14
    noclipBtn.Parent = frame
    ui.noclipBtn = noclipBtn
    local ncCorner = Instance.new("UICorner")
    ncCorner.CornerRadius = UDim.new(0, 6)
    ncCorner.Parent = noclipBtn

    -- vehicle fly
    local vehicleBtn = Instance.new("TextButton")
    vehicleBtn.Size = UDim2.new(1, -20, 0, 34)
    vehicleBtn.Position = UDim2.new(0, 10, 0, 116)
    vehicleBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    vehicleBtn.BorderSizePixel = 0
    vehicleBtn.Text = "Vehicle Fly: OFF  [V]"
    vehicleBtn.TextColor3 = Color3.fromRGB(240, 240, 240)
    vehicleBtn.Font = Enum.Font.GothamBold
    vehicleBtn.TextSize = 14
    vehicleBtn.Parent = frame
    ui.vehicleBtn = vehicleBtn
    local vCorner = Instance.new("UICorner")
    vCorner.CornerRadius = UDim.new(0, 6)
    vCorner.Parent = vehicleBtn

    -- speed
    local speedLabel = Instance.new("TextLabel")
    speedLabel.Size = UDim2.new(0, 60, 0, 26)
    speedLabel.Position = UDim2.new(0, 10, 0, 158)
    speedLabel.BackgroundTransparency = 1
    speedLabel.Text = "Speed:"
    speedLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
    speedLabel.Font = Enum.Font.Gotham
    speedLabel.TextSize = 14
    speedLabel.TextXAlignment = Enum.TextXAlignment.Left
    speedLabel.Parent = frame

    local speedBox = Instance.new("TextBox")
    speedBox.Size = UDim2.new(1, -90, 0, 26)
    speedBox.Position = UDim2.new(0, 70, 0, 158)
    speedBox.BackgroundColor3 = Color3.fromRGB(55, 55, 62)
    speedBox.BorderSizePixel = 0
    speedBox.Text = tostring(speed)
    speedBox.TextColor3 = Color3.fromRGB(240, 240, 240)
    speedBox.Font = Enum.Font.Gotham
    speedBox.TextSize = 14
    speedBox.PlaceholderText = "60"
    speedBox.PlaceholderColor3 = Color3.fromRGB(150, 150, 150)
    speedBox.ClearTextOnFocus = false
    speedBox.Parent = frame
    ui.speedBox = speedBox
    local boxCorner = Instance.new("UICorner")
    boxCorner.CornerRadius = UDim.new(0, 6)
    boxCorner.Parent = speedBox

    track(speedBox:GetPropertyChangedSignal("Text"):Connect(function()
        local filtered = (speedBox.Text:gsub("%D", ""))
        if filtered ~= speedBox.Text then speedBox.Text = filtered end
    end))
    track(speedBox.FocusLost:Connect(function()
        local n = tonumber(speedBox.Text) or 60
        n = math.clamp(math.floor(n), 1, 1000)
        speed = n
        speedBox.Text = tostring(n)
    end))

    track(flyBtn.MouseButton1Click:Connect(toggleFly))
    track(noclipBtn.MouseButton1Click:Connect(toggleNoclip))
    track(vehicleBtn.MouseButton1Click:Connect(toggleVehicleFly))

    -- hover
    track(flyBtn.MouseEnter:Connect(function()
        if not flying then flyBtn.BackgroundColor3 = Color3.fromRGB(85, 85, 95) end
    end))
    track(flyBtn.MouseLeave:Connect(function()
        if not flying then flyBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80) end
    end))
    track(noclipBtn.MouseEnter:Connect(function()
        if not noclipEnabled then noclipBtn.BackgroundColor3 = Color3.fromRGB(85, 85, 95) end
    end))
    track(noclipBtn.MouseLeave:Connect(function()
        if not noclipEnabled then noclipBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80) end
    end))
    track(vehicleBtn.MouseEnter:Connect(function()
        if not vehicleFlyEnabled then vehicleBtn.BackgroundColor3 = Color3.fromRGB(85, 85, 95) end
    end))
    track(vehicleBtn.MouseLeave:Connect(function()
        if not vehicleFlyEnabled then vehicleBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80) end
    end))
    track(closeBtn.MouseEnter:Connect(function()
        closeBtn.BackgroundColor3 = Color3.fromRGB(200, 60, 60)
    end))
    track(closeBtn.MouseLeave:Connect(function()
        closeBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 80)
    end))

    makeDraggable(frame, titleBar)

    -- close everything
    track(closeBtn.MouseButton1Click:Connect(function()
        stopFly()
        stopNoclip()
        vehicleFlyEnabled = false
        stopVehicleFly()
        if vehicleMonitorConnection then
            vehicleMonitorConnection:Disconnect()
            vehicleMonitorConnection = nil
        end
        disconnectAll()
        if ui.gui then ui.gui:Destroy() end
        ui = {}
    end))
end

-- ============ KEYBINDS ============
track(UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.KeyCode == Enum.KeyCode.E then
        toggleFly()
    elseif input.KeyCode == Enum.KeyCode.V then
        toggleVehicleFly()
    end
end))

-- ============ BOOT ============
buildGui()

track(player.CharacterAdded:Connect(function(char)
    if flying then stopFly() end
    if vehicleFlyActive then stopVehicleFly() end
    updateFlyButton()
    local humanoid = char:WaitForChild("Humanoid", 5)
    if humanoid then restoreRagdollStates(humanoid) end
end))

Features & Information

Free Source Code AI FLY SCRIPT
#Free#Keyless#Source Code#Fly

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts