Detecting when player is at the egde of the screen?

Ok so in my fighting game I’m trying to make this system where if both players are at the edge of the screen you can’t walk further back I’m not exactly sure what this is called, but I know this feature is in Street Fighter and so I tried to include it in my game and it looks like this

My current issue with this is when the opponent is at the edge of the screen, but you’re not I don’t wanna disable movement here’s a video of what I mean


Here’s all the code for it. Basically it gets Player2 is (the opponent) and I guess checks where it is on the screen and then I just check the distance from the left and if it’s at a certain point I do stuff.

local Vector,IsOnScreen = workspace.CurrentCamera:WorldToScreenPoint(Player2.HurtBox.Position)
local Vector = Vector2.new(math.clamp(Vector.X, 0, workspace.CurrentCamera.ViewportSize.X), 0)
local DistanceFromLeft = (Vector - Vector2.new(0,0)).Magnitude
--local DistanceFromRight = (Vector - Vector2.new(workspace.CurrentCamera.ViewportSize.X,0)).Magnitude
if (DistanceFromLeft >= 1210 or DistanceFromLeft <= 200) then
	--| if they're at the edge of the screen, but walking forward then give them speed back
	if (Main.UIS:IsKeyDown(Enum.KeyCode.D) and CharacterManager.CurrentFacingDirection == 1) or 
		Main.UIS:IsKeyDown(Enum.KeyCode.A) and (CharacterManager.CurrentFacingDirection == -1) then
		OpponentAtEdge = false
		CharacterManager.AtEdge = false
		CharacterManager:AdjustMovement("WalkSpeed",17)
	else
		--| they're at the edge of the screen lower walkspeed so they can't walk further back
		CharacterManager.AtEdge = true
		CharacterManager:AdjustMovement("WalkSpeed",0)
	end
else
	CharacterManager.AtEdge = false
	CharacterManager:AdjustMovement("WalkSpeed",17)
end

im not 100% sure this would work but its worth a try
you could make 2 parts or 2 attachments at the edge of the camera (i suggest attachments because you wont need to move them with the camera you just attach it to the camera with an offset) then you check for each player if their X or Z is near the attachment’s X or Z, then if so push them back. again im not 100% this would work