How would I make a part always be behind another part, no matter the size or rotation?

Basically, I posted this earlier but without alot of context so it was just all confusing,
I’m making an npc that’s able to find cover behind walls, what I need to do is make the script create a part behind a wall no matter the size, the script works on the Z axis as shown here:
Screen Shot 2024-01-13 at 6.11.24 PM
with the size of the transparent wall modified:
Screen Shot 2024-01-13 at 6.12.32 PM
however with the X axis:


basically, I always want the bricks facing towards the red part to always be behind the transparent wall, no matter the size of the transparent wall. How would I do this? My current script is:

local character = script.Parent
local range = 100
local target = workspace.Target
while task.wait(1) do
	for i,v in pairs(workspace:GetDescendants()) do
		if v.ClassName == "Part" then
			if v.Parent ~= character and v ~= target then
				if (character.HumanoidRootPart.Position - v.Position).Magnitude <= 100 then
					if v.Name ~= "Part" then
						local lookatpart = Instance.new("Part")
						lookatpart.Parent = workspace
						lookatpart.CFrame = v.CFrame
						lookatpart.Anchored = true
						lookatpart.CanCollide = false
						lookatpart.Transparency = 0
						lookatpart.Size = Vector3.new(1,1,2)	
						lookatpart.CFrame = CFrame.lookAt(lookatpart.Position, target.Position)
						lookatpart.CFrame = lookatpart.CFrame:ToWorldSpace(CFrame.new(0, 0, v.Size.Z / 2 + lookatpart.Size.Z / 2))	
						local direction = (workspace.Target.Position - lookatpart.Position)
						local cast = workspace:Raycast(lookatpart.Position,direction)
						if cast.Instance == workspace.Target then
							print("target found")
							-- success
						else 
							-- no cast
							print("cover found")
						end
					end
				end
			end
		end
	end
end
-- its not finished, i really dont code like this lol ill fix it later

Since this is now the repo I can not reference the person but like said in OP you should use the inversed LookVector of the wall

And that will never be relative to either size or rotation

The only thing you have to keep in mind is - the sizing wont change the facing of a part
so just because YOU know that the long size should be the front, your roblox cant just interpret that! YOU have to scale/size your wall in such a way that the front face roblox knows is the same front face that YOU imagine it should be!

Overall:

  1. Don’t repost
  2. Size your models with respect to the faces

Hope this helped!

Edit: Where has the reply of the person also pointing the reposting out gone?