How would I make a camera topdown border when a wall is visible on screen

You know in like every 2d rpg game when you reach a border wall, the camera stops moving in the direction the player is moving before they hit the wall, like just when they have seen the wall. because there is nothing beyond it and it looks bad if you can see nothingness or open world past the wall.

Well I am wondering how to make it so my top down-ish camera will stop moving further in the direction of the wall when the player is moving that way.

pls keep in mind i am quite new to scripting
this is the script i am using for top down view:

local rs = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local distance = 30
local cf = CFrame.fromOrientation(math.rad(-60), math.rad(0), 0) * CFrame.new(0, 0, distance)

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

rs:BindToRenderStep("camLock", Enum.RenderPriority.Camera.Value + 1, function()
	if (player.Character and player.Character:FindFirstChild("HumanoidRootPart")) then
		workspace.CurrentCamera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * cf
	end
end)

and this is what it looks like on camera:

This is what i am going for but on roblox studio: