Cloning a Part and Positioning it Adjacent to the Original

I’m trying to make it so when clicked, this part will duplicate itself and position itself adjacent to the original on the clicked face, like so:

With the gray part being the original part, and the green part being the part just cloned. I’m using Raycasts to do this. I’m currently positioning the part like this:

clonedPart.Position = hitPart.Position + (hitNormal * hitPart.Size)

This works fine when the part isn’t orientated, however as soon as I rotate the part this breaks.

I’m not sure where to get started with fixing this, any help would be appreciated.

I’d recommend multiplying CFrames so it moves relative to the part’s LookVector:

clonedPart.CFrame = hitPart.CFrame * CFrame.new(hitNormal * hitPart.Size)

Hi, thank you for your reply.
I should’ve included that I’ve already tried this, and it results in a similar issue.

Just set the part’s CFrame to the other part’s CFrame, as well as copy any properties and set it to how you like. Note if that the part is unanchored and CanCollide is on, this won’t work well.

The part is cloned, the properties aren’t a problem.
Positioning the part is what I’m having trouble with.

Is the part anchored? That will disposition the clone.

Yes, the part will always be anchored.

I’m trying to think, give me a minute.

Seems I’ve found a solution.
AveragePhonkEnjoyer’s solution works, when I get the normal of the part if it wasn’t rotated.
So you just need to get the NormalID from the normal and use Vector3.fromNormalID and supply that instead of the actual, rotated normal.

Thank you for your help!

1 Like