
Key RequiredUniversal

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local flying = true
local speed = 50
local moveDirection = Vector3.new(0,0,0)
local keys = {
W = false,
A = false,
S = false,
D = false,
Space = false,
LeftControl = false,
}
-- Create BodyVelocity
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(1e5,1e5,1e5)
bodyVelocity.Velocity = Vector3.new(0,0,0)
bodyVelocity.Parent = rootPart
local function updateMoveDirection()
local camCFrame = workspace.CurrentCamera.CFrame
local forward = camCFrame.LookVector
local right = camCFrame.RightVector
local up = Vector3.new(0,1,0)
local dir = Vector3.new(0,0,0)
if keys.W then dir = dir + forward end
if keys.S then dir = dir - forward end
if keys.A then dir = dir - right end
if keys.D then dir = dir + right end
if keys.Space then dir = dir + up end
if keys.LeftControl then dir = dir - up end
if dir.Magnitude > 0 then
moveDirection = dir.Unit
else
moveDirection = Vector3.new(0,0,0)
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode.Name
if keys[key] ~= nil then
keys[key] = true
updateMoveDirection()
end
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode.Name
if keys[key] ~= nil then
keys[key] = false
updateMoveDirection()
end
end
end)
-- MOBILE BUTTONS SETUP --
if UserInputService.TouchEnabled then
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "FlyControls"
screenGui.Parent = player:WaitForChild("PlayerGui")
local function createButton(name, pos, text)
local btn = Instance.new("TextButton")
btn.Name = name
btn.Size = UDim2.new(0, 60, 0, 60)
btn.Position = pos
btn.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
btn.BackgroundTransparency = 0.5
btn.TextColor3 = Color3.new(1,1,1)
btn.Text = text
btn.Parent = screenGui
btn.AutoButtonColor = true
btn.Font = Enum.Font.SourceSansBold
btn.TextScaled = true
return btn
end
-- Create buttons for controls
local btnW = createButton("W", UDim2.new(0.1, 0, 0.7, 0), "↑")
local btnA = createButton("A", UDim2.new(0.02, 0, 0.8, 0), "←")
local btnS = createButton("S", UDim2.new(0.1, 0, 0.85, 0), "↓")
local btnD = createButton("D", UDim2.new(0.18, 0, 0.8, 0), "→")
local btnUp = createButton("Space", UDim2.new(0.9, 0, 0.75, 0), "↑Up")
local btnDown = createButton("LeftControl", UDim2.new(0.9, 0, 0.85, 0), "↓Down")
-- Helper function to handle touch input for buttons
local function buttonTouch(btn, key)
btn.TouchStarted:Connect(function()
keys[key] = true
updateMoveDirection()
end)
btn.TouchEnded:Connect(function()
keys[key] = false
updateMoveDirection()
end)
btn.TouchMoved:Connect(function(touch)
-- In case finger moves off button, reset
local pos = touch.Position
local absPos = btn.AbsolutePosition
local size = btn.AbsoluteSize
if pos.X < absPos.X or pos.X > absPos.X + size.X or pos.Y < absPos.Y or pos.Y > absPos.Y + size.Y then
keys[key] = false
updateMoveDirection()
end
end)
end
buttonTouch(btnW, "W")
buttonTouch(btnA, "A")
buttonTouch(btnS, "S")
buttonTouch(btnD, "D")
buttonTouch(btnUp, "Space")
buttonTouch(btnDown, "LeftControl")
end
-- Main loop
RunService.RenderStepped:Connect(function()
if flying then
bodyVelocity.Velocity = moveDirection * speed
humanoid.PlatformStand = true
else
bodyVelocity.Velocity = Vector3.new(0,0,0)
humanoid.PlatformStand = false
end
end)No comments yet for this script.



![Item Spawner - Bypass Gamepass [OPEN-SOURCE]](https://scriptblox.com/images/sb/rbx-2736e5de37c3d8bc17e5e9bd07d73e38-cc0a9732451c.png)