How can I make a cframe from the position of a part, and the orientation of another part?

Just the title, very simple question.

1 Like
local cf = (part2.CFrame - part2.CFrame.Position) + part1.CFrame.Position

Breaking it down:

part2.CFrame - part2.CFrame.Position will only get the rotational part of part2’s CFrame, since you are subtracting its position from itself which gives you nothing
+ part1.CFrame.Position will then add the position vector of part1 back to the CFrame

2 Likes

Uhh, for some reason the orientation doesn’t change.

Actually the whole thing is a bit off.

I would go over the code and make sure the correct variables are used and the part to derive the orientation from actually has a different orientation


So the middle of the big transparent red blocks are supposed to spawn right in front of my eyes, but instead the left one spawned inside of me.
Is the (part2.CFrame - part2.CFrame.Position) supposed to be the eyes or the rotation part?

I explained what the variables are in my first post

Oh my bad, I switched the variables, and it works perfectly now, thanks

Im surprised almost nobody knows about one CFrame property which is .Rotation. I always see people subract a cframe by its position instead of taking the rotation.

You could just take the position directly instead of taking the position of the cframe.

2 Likes

I could’ve sworn that it wasn’t there on the API reference, thanks for telling me

That was done out of habit, since some instances that have a CFrame property does not necessarily have a dedicated position property, so I’m just safeguarding there

1 Like