--// Services local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local RS = game:GetService("RunService") local LP = Players.LocalPlayer local Cam = workspace.CurrentCamera --// State local flying = false local velocity = Vector3.zero local speed = 50 local sensitivity = 0.002 local camRot = Vector2.new() local con --// Movement keys local moveKeys = { W = true, A = true, S = true, D = true, Space = true, LeftControl = false } --// Input Begin UIS.InputBegan:Connect(function(input, gp) if gp then return end if input.KeyCode == Enum.KeyCode.LeftShift then flying = not flying if flying then Cam.CameraType = Enum.CameraType.Scriptable camRot = Vector2.new(Cam.CFrame:ToOrientation()) UIS.MouseBehavior = Enum.MouseBehavior.LockCenter UIS.MouseIconEnabled = false con = RS.RenderStepped:Connect(function(dt) local delta = UIS:GetMouseDelta() camRot = camRot + Vector2.new(-delta.Y, -delta.X) * sensitivity camRot = Vector2.new(math.clamp(camRot.X, -1.5, 1.5), camRot.Y) local rot = CFrame.Angles(0, camRot.Y, 0) * CFrame.Angles(camRot.X, 0, 0) local moveDir = Vector3.zero if moveKeys.W then moveDir += Vector3.new(0, 0, -1) end if moveKeys.S then moveDir += Vector3.new(0, 0, 1) end if moveKeys.A then moveDir += Vector3.new(-1, 0, 0) end if moveKeys.D then moveDir += Vector3.new(1, 0, 0) end if moveKeys.Space then moveDir += Vector3.new(0, 1, 0) end if moveKeys.LeftControl then moveDir += Vector3.new(0, -1, 0) end if moveDir.Magnitude > 0 then velocity = velocity:Lerp((rot * moveDir.Unit) * speed, 0.25) else velocity *= 0.85 end Cam.CFrame = Cam.CFrame + velocity * dt Cam.CFrame = CFrame.new(Cam.CFrame.Position) * rot end) else if con then con:Disconnect() end Cam.CameraType = Enum.CameraType.Custom UIS.MouseBehavior = Enum.MouseBehavior.Default UIS.MouseIconEnabled = true end else local key = input.KeyCode.Name if moveKeys[key] ~= nil then moveKeys[key] = true end end end) --// Input End UIS.InputEnded:Connect(function(input) local key = input.KeyCode.Name if moveKeys[key] ~= nil then moveKeys[key] = false end end)