Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFrame & Rotating Problem?

Asked by 8 years ago

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))
0
Are you sure the parts are facing the same way? P100D 590 — 8y
0
Yes? Anthony9960 210 — 8y

1 answer

Log in to vote
1
Answered by
DevSean 270 Moderation Voter
8 years ago

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!

Ad

Answer this question