Is there code to know when the player left an object

So I would like to know if there is code to know when an object leaves an object. is there?

if(playerName.x<objectName.x){
//your code here
}

thanks I’ll try it

one thing with it is that I don’t quite understand it because it uses the x and y coordinates and it doesn’t work well but thanks for trying to help