How do I make this part rotate with head?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make the part that is welded to body rotate with it like single model

  1. What is the issue? Include screenshots / videos if possible!

When im turning around, the part is hitting in the x (or z) axis

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to make childadded event handler, but nothing changed

Here’s the code:

game.Players.PlayerAdded:Connect(function(player)
	if player:IsDescendantOf(game.Players) then
		local char = player.Character or player.CharacterAdded:Wait()
		local head = char:WaitForChild("Head")
		local facepart = char:WaitForChild("FacePart")

		facepart.Anchored = false

		local newCFrame = head.CFrame * CFrame.new(0, 3, -3) * CFrame.Angles(math.rad(45),0,0)
				facepart.CFrame = newCFrame

		local localPosition = facepart.CFrame:PointToObjectSpace(newCFrame.Position)
		local weld = Instance.new("Weld")
		weld.Parent = facepart
		weld.Part0 = head
		weld.Part1 = facepart
		weld.C1 = CFrame.new(localPosition) * CFrame.Angles(math.rad(-45),0,0)
	end
end)

Thanks.

1 Like

What is local facepart = char:WaitForChild("FacePart") ?
I mean that FacePart thing, is a model? a part?

When you do this line to that facepart, you already positioned in the right place?
local newCFrame = head.CFrame * CFrame.new(0, 3, -3) * CFrame.Angles(math.rad(45),0,0)

If the part is already positioned in the right place, use a WeldConstraint, not a Weld, or you would need to set the Offset again:

		local weld = Instance.new("WeldConstraint")
		weld.Part0 = head
		weld.Part1 = facepart
		weld.Parent = facepart

And when using WeldContraint this becomes useless:
weld.C1 = CFrame.new(localPosition) * CFrame.Angles(math.rad(-45),0,0)
No needing more adjustments if you already set the part position with local newCFrame

its not positioned in right place, so im using cframe

facepart is the thing i want to use like the controller of knockback, like with facepart i can control what way it knockbacks

Okay i will try that then, thanks

Thank you so much! it worked! Now my knockback is fixed

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.