How to get the closest point of a wall from character

Basically im trying to create a cover system like in GTA 5 and I know how to do everything needed to complete this task except the initial positioning after I ray cast for the wall (if that makes sense) like I want to be able to cover to the closest point of the wall to my character and to do that I need to be able to find the position of the wall closest to the character. I hope that is straight forward enough, I just need some guidance. (The raycast will be 4 directions from the root part so I cant use it to determine position.)

I’m assuming when using the raycast you have a hitPosition, for example

local ray = Ray.new(Root.CFrame.Position,Vector3.new(0,-500,0))
local otherPart, hitPosition = workspace:FindPartOnRay(ray, Character)
	if otherPart then
	local target = Root.Position.Y - hitPosition.Y
       Root.CFrame =  Root.CFrame - Vector3.new(0,target,0) 
end

This was a script I used a whole back but basically take the length of the rays (In this case y position) and subtract it with the characters y position, to get to the player to there destination which was where the ray hit