Trying to create a 3d Fighting Game Style Camera

Ello, i am trying to create a fighting game style camera, kinda like the one from super smash bros.

–Script–

local rep = game:GetService("ReplicatedStorage")
local run = game:GetService("RunService")

local remotes = rep:WaitForChild("RemoveEvents")
local FocusPart = game.Workspace:WaitForChild("FocusPart")

local PlayerTransfrom = {}


local YOffset = 2.0
local MinDistance = 7.5

local XMin, XMax, YMin, YMax = 0, 0, 0, 0


remotes.Player.OnServerEvent:Connect(function(plr)
	table.insert(PlayerTransfrom, plr)
	
	run.Heartbeat:Connect(LateUpdate)
end)


function LateUpdate()
	if #PlayerTransfrom == 0 then return end
	
	YMin = FocusPart.Position.X
	XMin = FocusPart.Position.Y
	
	for _, plr: Player in pairs(PlayerTransfrom) do
		local rootPart = plr.Character.PrimaryPart
		
		if (rootPart.Position.X < XMin) then
			XMin = rootPart.Position.X
		end
		
		if (rootPart.Position.X > XMax) then
			XMax = rootPart.Position.X
		end
		
		if (rootPart.Position.Y < YMin) then
			YMin = rootPart.Position.X
		end
		
		if (rootPart.Position.Y > YMax) then
			YMax = rootPart.Position.Y
		end
		
		local xMiddle = (XMin + XMax) / 2
		local yMiddle = (YMin + YMax) / 2
		
		local distance = XMax - XMin
		
		if (distance < MinDistance) then
			distance = MinDistance
		end
		
		script.Parent.CFrame = CFrame.new(Vector3.new(xMiddle, yMiddle, -distance))
	end
end

has you can see it kinda works??
–Video–