Part isnt welding

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 set the facepart in specific position and rotation, and then weld the part so it sets in that position and rotation

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

When Im testing, the part is in the position and rotation I need, but it doesnt weld.
Here’s short video
P.S. Sorry for very low quality video, I dont know why is it like this

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

Yes, but there wasn’t any topics about that

Error that I got: ServerScriptService.facepart:12: invalid argument #2 (Vector3 expected, got CFrame) - Server - facepart:12

Script:

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, 2, -2) * CFrame.Angles(math.rad(45), 0, 0)
		facepart.CFrame = newCFrame

		local localPosition = facepart.CFrame:PointToObjectSpace(newCFrame)
		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

Welds are positioned using Vector3. As the error says you need to use a Vector3, not a CFrame.

usually you change a CFrame to normal position by doing

CFrameCodeHere.Position
1 Like

Yes but it gives me error for line 12 which is

local localPosition = facepart.CFrame:PointToObjectSpace(newCFrame)

1 Like