Fly script
Key RequiredUniversal

Fly script

Universal Scriptscripttester191scripttester191 1K views 42 executesUpdated Dec 8, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•88 lines (2435 chars)
local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local flying = false
local speed = 500

local HRP
local Humanoid

local move = {
	forward = false,
	back = false,
	left = false,
	right = false,
	up = false,
	down = false
}

-- Setup character
local function setupCharacter(char)
	HRP = char:WaitForChild("HumanoidRootPart")
	Humanoid = char:WaitForChild("Humanoid")
end

if player.Character then
	setupCharacter(player.Character)
end

player.CharacterAdded:Connect(function(char)
	setupCharacter(char)
end)

-- Input
UIS.InputBegan:Connect(function(input, gpe)
	if gpe then return end

	if input.KeyCode == Enum.KeyCode.E then
		flying = not flying

		if flying then
			Humanoid.PlatformStand = true
			print("Flight ON")
		else
			Humanoid.PlatformStand = false
			print("Flight OFF")
		end
	end

	if input.KeyCode == Enum.KeyCode.W then move.forward = true end
	if input.KeyCode == Enum.KeyCode.S then move.back = true end
	if input.KeyCode == Enum.KeyCode.A then move.left = true end
	if input.KeyCode == Enum.KeyCode.D then move.right = true end
	if input.KeyCode == Enum.KeyCode.Space then move.up = true end
	if input.KeyCode == Enum.KeyCode.LeftControl then move.down = true end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W then move.forward = false end
	if input.KeyCode == Enum.KeyCode.S then move.back = false end
	if input.KeyCode == Enum.KeyCode.A then move.left = false end
	if input.KeyCode == Enum.KeyCode.D then move.right = false end
	if input.KeyCode == Enum.KeyCode.Space then move.up = false end
	if input.KeyCode == Enum.KeyCode.LeftControl then move.down = false end
end)

-- Flight loop
RunService.RenderStepped:Connect(function()
	if flying and HRP then
		local cam = workspace.CurrentCamera
		local direction = Vector3.zero

		if move.forward then direction += cam.CFrame.LookVector end
		if move.back then direction -= cam.CFrame.LookVector end
		if move.left then direction -= cam.CFrame.RightVector end
		if move.right then direction += cam.CFrame.RightVector end
		if move.up then direction += Vector3.new(0,1,0) end
		if move.down then direction -= Vector3.new(0,1,0) end

		if direction.Magnitude > 0 then
			HRP.Velocity = direction.Unit * speed
		else
			HRP.Velocity = Vector3.zero
		end

		HRP.CFrame = CFrame.new(HRP.Position, HRP.Position + cam.CFrame.LookVector)
	end
end)

Features & Information

E to fly

Community Comments (2)

trok*etrok*eDec 8, 2025

not working

Replying to @trok*e
scripttester191scripttester191Dec 8, 2025

@troke its working js press e tho

More Scripts for Universal Scripts