Facing issues when changing the CFrame of a part

clone.PrimaryPart.CFrame = player.Character.HumanoidRootPart.CFrame + player.Character.HumanoidRootPart.CFrame.lookVector*15
	clone.PrimaryPart.CFrame = CFrame.new(Vector3.new(clone.PrimaryPart.Position.X, position.Position.Y, clone.PrimaryPart.Position.Z))

This is my code that’s supposed to change the CFrame of ‘clone’ (a cloned model that’s now in the workspace).
In line one it places the model in front of the humanoidRootPart. Line 2 changes the Y axis of the position. (position is just another varible)

Without line 2 (its floating but facing the humanoidRootPart): image

With line 2 (its not floating anymore but its also not facing the humanoidRootPart anymore):image

How I want it to be (not floating and facing the HumanoidRootPart) :image

How do I place the model on top of the part below (position variable) without reseting the facing direction?

I believe the orientation is changing because constructing a new CFrame and just passing positional values will yield no special settings for CFrame’s angular matrix.

You can actually simplify this code a good bit using CFrame.new(vec3 pos, vec3 lookAt):

PrimaryPart.CFrame = CFrame.new(PrimaryPart.Position, (player.Character.HumanoidRootPart.Position * Vector3.new(1,0,1)))

This code should maintain all positional vectors while allowing the PrimaryPart to face player’s HumanoidRootPart.

1 Like

That didn’t work too well :sweat_smile:
image

clone.PrimaryPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-15)

?

2 Likes

This did the same thing as line 1. Didn’t work either

I fixed it by now.

clone.PrimaryPart.CFrame = player.Character.HumanoidRootPart.CFrame + player.Character.HumanoidRootPart.CFrame.lookVector*15
	clone.PrimaryPart.CFrame = CFrame.new(Vector3.new(clone.PrimaryPart.Position.X, position.Position.Y, clone.PrimaryPart.Position.Z), Vector3.new(player.Character.HumanoidRootPart.Position.X, position.Y, player.Character.HumanoidRootPart.Position.Z))

position is a variable.