RTS style camera control with middle mouse button

Hello, I am trying to make a system where the player can control a top-down camera using the middle mouse button to go forward, left, right and backwards.

I am pretty unfamiliar with this topic, so I did some research and ended up with this script

local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local UIS = game:GetService('UserInputService')

-- place the camera high in the air, looking down at the ground
local startingPos = Vector3.new(200, 400, 100)
local downwardLookAngle =  CFrame.Angles(-math.rad(60), 0, 0)
cam.CFrame = CFrame.new(startingPos) * downwardLookAngle
cam.FieldOfView = 80

-- zooms in / zooms out
Mouse.WheelForward:Connect(function()
	if cam.FieldOfView - 5 > 15 then
		cam.FieldOfView = cam.FieldOfView - 5
	end
end)
Mouse.WheelBackward:Connect(function()
	if cam.FieldOfView + 5 < 80 then
		cam.FieldOfView = cam.FieldOfView + 5
	end
end)

-- Detects the mouses position and moves the camera's cFrame accordingly (kinda)
local mmb = false
UIS.InputBegan:Connect(function(key)
	if key.UserInputType == Enum.UserInputType.MouseButton3 then
		mmb = true
	end
	UIS.InputChanged:Connect(function(InputObject)
		if InputObject.UserInputType == Enum.UserInputType.MouseMovement and mmb == true then
			cam.CFrame = cam.CFrame + cam.CFrame.RightVector*key.Delta.X*0.01 - cam.CFrame.UpVector*key.Delta.Y*0.01
		end
	end)
end)
UIS.InputEnded:Connect(function(key)
	if key.UserInputType == Enum.UserInputType.MouseButton3 then
		mmb = false
	end

end)


The camera moves ( for the most part) but not in a smooth or controllable away. In my testing, the camera only moves left, right and down sometimes. How could I make it move forward, backward, left and right?