-- Iron Man Fly (Xeno OK)
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local flying = false
local bv, bg
local speed = 80
local minSpeed = 20
local maxSpeed = 250
local function startFly()
if flying then return end
flying = true
bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e6,1e6,1e6)
bv.Velocity = Vector3.zero
bv.Parent = hrp
bg = Instance.new("BodyGyro")
bg.MaxTorque = Vector3.new(1e6,1e6,1e6)
bg.Parent = hrp
end
local function stopFly()
flying = false
if bv then bv:Destroy() end
if bg then bg:Destroy() end
bv, bg = nil, nil
end
-- PHÍM ĐIỀU KHIỂN
UIS.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.F then
if flying then stopFly() else startFly() end
end
-- tăng tốc
if input.KeyCode == Enum.KeyCode.Equals or input.KeyCode == Enum.KeyCode.KeypadPlus then
speed = math.clamp(speed + 10, minSpeed, maxSpeed)
end
-- giảm tốc
if input.KeyCode == Enum.KeyCode.Minus or input.KeyCode == Enum.KeyCode.KeypadMinus then
speed = math.clamp(speed - 10, minSpeed, maxSpeed)
end
end)
RunService.Heartbeat:Connect(function()
if flying and bv and bg then
local cam = workspace.CurrentCamera
local look = cam.CFrame.LookVector
-- bay theo hướng nhìn + hơi ngửa người (Iron Man)
bv.Velocity = look * speed
bg.CFrame =
CFrame.new(hrp.Position, hrp.Position + look)
* CFrame.Angles(math.rad(-25), 0, 0)
end
end)
-- reset khi respawn
plr.CharacterAdded:Connect(function(c)
char = c
hrp = char:WaitForChild("HumanoidRootPart")
stopFly()
end)