How would I make ledge grabbing?

Just curious, figured it has something to do with raycasting. Anyone know how to do this? The confusing part to me that I’m trying to figure out is how you get the top surface position of the part that is in front of your character.

I’d probably just raycast in front of the character at three different heights. One at their waist, one at their neck, and one a bit above their head (probably enough so that if the player were to grab onto the ledge, they could still stand vertically).

You can then determine that if the top-two-most raycasts don’t hit anything but the bottom one does, there is a ledge to grab on to.