Get orientation from a Raycast hit

I want to create a gun that makes a surface at the position of a raycast hit. The position works, however, I also want to orient the part so it’s equal with the hit’s surface.

This is how the gun works right now.

This is how the part is currently being oriented:

This is how I want the part to be oriented:

This is my code:

I’ve searched the forum but I didn’t really find an answer. Would anyone help?


The raycast normal has the info needed to align with the surface orientation.

This link should be great for just this :slight_smile:


1 Like

Use raycast normal to achieve that and set the cframe of a part instead of a position. Try something like this:

p.CFrame =, Pos + Normal)

You may have to multiply this by some constant depending on your part

1 Like

Thanks, I actually found a post about this somewhere, it has the same solution as you.

1 Like