How to rotate a part taking into account it's position and direction?

I think this worked, can’t really tell. Thank you!