How exactly does a "look at" script work?

I’m sorta new to programming and even though I know how to create a “look at” script using blueprints, I really want to know how a “look at” script actually calculates the rotation and then sets it since I prefer to write my own functions as a learning experience.

You can just do a google search to find out the math for that

There’s literally a “Find Look At Rotation” Node.