local player = game:GetService("Players").LocalPlayer local uis = game:GetService("UserInputService") local runService = game:GetService("RunService") local flying = false local speed = 50 local toggleKey = Enum.KeyCode.F local bodyVelocity local bodyGyro local function toggleFly() flying = not flying local character = player.Character if not character then return end local humanoid = character:FindFirstChild("Humanoid") local rootPart = character:FindFirstChild("HumanoidRootPart") if not humanoid or not rootPart then return end if flying then humanoid.PlatformStand = true bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.Velocity = Vector3.new(0,0,0) bodyVelocity.MaxForce = Vector3.new(4000, 4000, 4000) bodyVelocity.Parent = rootPart bodyGyro = Instance.new("BodyGyro") bodyGyro.MaxTorque = Vector3.new(4000, 4000, 4000) bodyGyro.P = 1000 bodyGyro.D = 50 bodyGyro.CFrame = rootPart.CFrame bodyGyro.Parent = rootPart runService:BindToRenderStep("Fly", 0, function() if not flying or not character or not rootPart then return end local moveDirection = Vector3.new(0,0,0) local camera = workspace.CurrentCamera if uis:IsKeyDown(Enum.KeyCode.W) then moveDirection = moveDirection + camera.CFrame.LookVector end if uis:IsKeyDown(Enum.KeyCode.S) then moveDirection = moveDirection - camera.CFrame.LookVector end if uis:IsKeyDown(Enum.KeyCode.A) then moveDirection = moveDirection - camera.CFrame.RightVector end if uis:IsKeyDown(Enum.KeyCode.D) then moveDirection = moveDirection + camera.CFrame.RightVector end if uis:IsKeyDown(Enum.KeyCode.Space) then moveDirection = moveDirection + Vector3.new(0,1,0) end if uis:IsKeyDown(Enum.KeyCode.LeftControl) then moveDirection = moveDirection + Vector3.new(0,-1,0) end if moveDirection.Magnitude > 0 then moveDirection = moveDirection.Unit * speed end bodyVelocity.Velocity = moveDirection bodyGyro.CFrame = camera.CFrame end) else humanoid.PlatformStand = false if bodyVelocity then bodyVelocity:Destroy() bodyVelocity = nil end if bodyGyro then bodyGyro:Destroy() bodyGyro = nil end runService:UnbindFromRenderStep("Fly") end end uis.InputBegan:Connect(function(input) if input.KeyCode == toggleKey then toggleFly() end end) player.CharacterAdded:Connect(function() if flying then task.wait(0.5) toggleFly() end end)