Hey, I’m having a weird part turning problem that happens when I change the cframe of another part. I have a part that’s called Hinge which controls the direction the player is shooting. However, when I change the cframe of the HumanoidRootPart, it for whatever reason rotates the Hinge back to it’s old rotation. This only happens about every other shot. (The Hinge is not connected to the HumanoidRootPart in any way)
body.HumanoidRootPart.CFrame = body.Aim.Hinge.CFrame--THIS IS THE LINE
“Full” script
local WeldConstraint = body.HumanoidRootPart.WeldConstraint
WeldConstraint.Part1 = body.HumanoidRootPart
body.Aim.Hinge.Position = character.HumanoidRootPart.Position
body.Aim.Hinge.BodyGyro.CFrame = body.Aim.Hinge.CFrame
body.Aim.Cylinder.BodyGyro.CFrame = body.Aim.Hinge.CFrame
body.HumanoidRootPart.CFrame = body.Aim.Hinge.CFrame--THIS IS THE LINE
WeldConstraint.Part1 = character.HumanoidRootPart
When I take out the line that I pointed out in the script it works 100% of the time. The video below shows what’s happening because of that line of code.
https://gyazo.com/b52825455582a35ea9181cef016115a9
If anyone know why this is happening please let me know. Also the whole purpose of the code shown is to rotate the player to face the way it’s punching, so it’s purely for looks. The player can punch fine without any problems, however it’ll look really weird as shown in the video below.
https://gyazo.com/b1441c1d030eb030c56dc8d4fc31f53d
Thanks for reading!
1 Like
you can use CFrame.lookAt
humrootpart.CFrame = CFrame.lookAt(humrootpart.Position,target.Position)
change the target position to the position you want
2 Likes
Is the body the character or is it the part that is being rotated? If it is the character I suggest you use align orientation you will be able to turn without affecting gravity and stuff.
1 Like
Thanks for the suggestion! I tried it out and got the same result when using CFrame.lookAt, as I did before.
This is what the player looks like

The reason there’s two HumanoidRootParts is so I can make the character face a certain direction without changing the direction the player is walking. So the character can look like it’s facing left when it’s walking forward. In the script the HumanoidRootPart that is within the body model is being rotated to face the direction of the Hinge.
Try align orientation with the rotating RootPart just make two attachments one on the RootPart and one at the position of the first attachment but make it look where you want the RootPart to look, with align orientation you can choose the align type as parallel; if you want to learn more here is the API Reference AlignOrientation | Roblox Creator Documentation
Sorry, I’m confused by what you mean when you said
Could you please clarify?
Also the HumanoidRootPart is welded to the other HumanoidRootPart. Does align orientation work on parts that are welded through a weldConstriant?
So basically you can put one inside the humanoid and then put a attachment in terrain with cframe like this Attachment2.CFrame = CFrame.lookAt(Attachment1.WorldPosition, --where you want the RootPart to face)
1 Like
Align Orientation is a constraint so it might work since it works with characters and characters have motor 6d
3 Likes