Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

CFrame & Rotating Problem?

This 1 line is my problem. This is supposed to put the "Part" in front of the HumanoidRootPart and change the Rotation to the HumanoidRootPart's Rotation. It changes the position correctly, but the rotation isn't correct. Help plz ;). Part is an instance that I didn't include in this code.

Part.CFrame = (script.Parent.HumanoidRootPart.CFrame + script.Parent.HumanoidRootPart.CFrame.lookVector * 2) * CFrame.Angles(math.rad(script.Parent.HumanoidRootPart.Rotation.X),math.rad(script.Parent.HumanoidRootPart.Rotation.Y),math.rad(script.Parent.HumanoidRootPart.Rotation.Z))

2 comments

0

Are you sure the parts are facing the same way?

0

Yes?

1 answer

✓ Accepted answer

You're actually already setting the rotation of the part when you change it's CFrame to the HumanoidRootPart's CFrame.

Part.CFrame = script.Parent.HumanoidRootPart.CFrame + script.Parent.HumanoidRootPart.CFrame.lookVector * 2

You could also do this like the following:

Part.CFrame = script.Parent.HumanoidRootPart.CFrame * CFrame.new(0, 0, -2)

If this helped, please mark it as the correct answer, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.