I dont have a script for that, but I do have a theory on this.
You take a point in front of the player, and do a constant trace down that, you check if it's a big enough gap downwards (by checking the distance the hit result returns), and you set the player to the ledge.
You can set the ledge by something like a path along it, and move it over/along that.
hope it gives you a good idea.
regards,