local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera local flySpeed = 50 local keys = { W = false, A = false, S = false, D = false, Space = false, LeftShift = false } UIS.InputBegan:Connect(function(input, processed) if processed then return end if keys[input.KeyCode.Name] ~= nil then keys[input.KeyCode.Name] = true end end) UIS.InputEnded:Connect(function(input) if keys[input.KeyCode.Name] ~= nil then keys[input.KeyCode.Name] = false end end) local function setupCharacter(character) local root = character:WaitForChild("HumanoidRootPart") local humanoid = character:WaitForChild("Humanoid") local attachment = Instance.new("Attachment") attachment.Parent = root local velocity = Instance.new("LinearVelocity") velocity.Attachment0 = attachment velocity.MaxForce = math.huge velocity.RelativeTo = Enum.ActuatorRelativeTo.World velocity.VectorVelocity = Vector3.zero velocity.Parent = root RunService.Heartbeat:Connect(function() if not character.Parent then return end local direction = Vector3.zero local look = camera.CFrame.LookVector local right = camera.CFrame.RightVector local forward = Vector3.new(look.X, 0, look.Z) local sideways = Vector3.new(right.X, 0, right.Z) if forward.Magnitude > 0 then forward = forward.Unit end if sideways.Magnitude > 0 then sideways = sideways.Unit end if keys.W then direction += forward end if keys.S then direction -= forward end if keys.D then direction += sideways end if keys.A then direction -= sideways end if keys.Space then direction += Vector3.yAxis end if keys.LeftShift then direction -= Vector3.yAxis end if direction.Magnitude > 0 then direction = direction.Unit end humanoid:ChangeState(Enum.HumanoidStateType.Freefall) velocity.VectorVelocity = direction * flySpeed end) end player.CharacterAdded:Connect(setupCharacter) if player.Character then setupCharacter(player.Character) end