I don’t understand how you want this code to check if the player is near the wall, this code will only run if the player touches something other than the wall. not neccessarrilly near the wall. how about an update function instead,
function Update(){
if(player.transform.position.x -wall.transform.position.x <= 5 || player.transform.position.x -wall.transform.position.x >= -5 || player.transform.position.z -wall.transform.position.z <= 5 || player.transform.position.z -wall.transform.position.z >= -5 || player.transform.position.y -wall.transform.position.y <= 5 || player.transform.position.y -wall.transform.position.y >= -5){
//do whatever you want to do
}
}
this if statement will run when you character is in proximity of this wall you speak of.
another possibility would be to simply create an invisible trigger outside of the box, and then use the OnTriggerEnter function