I am using a WeldConstraint to weld my part to the players character PrimaryPart which is the HumanoidRootPart. It doesn’t seem like I can use C0 in WeldConstraint so what should I do?
I am getting this error in the output:
Unable to cast Instance to CoordinateFrame
Can you show the error line? That error appears when you try to put an Instance
as a property which only accepts CFrame
s.
The Script:
Player.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Holder = Holder:Clone() -- Location to Holder and then cloning it
Holder:PivotTo(Character.HumanoidRootPart)
Holder.Parent = Character
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Part0 = Holder.PrimaryPart
WeldConstraint.Part1 = Character.PrimaryPart
WeldConstraint.C0 = WeldConstraint.Part0.CFrame:ToObjectSpace(WeldConstraint.Part1.CFrame)
WeldConstraint.Parent = WeldConstraint.Part0
end)
end)
Few things I see wrong:
:PivotTo()
only accepts CFrames, that’s why you should input Character.HumanoidRootPart.CFrame
instead.
WeldConstraint
s don’t have the C0
property unlike Weld
s. The only reason to use WeldConstraint
s over Weld
s (as far as I know) is to not have to set that property manually.
1 Like
Oops… Totally forgot that I hadn’t put CFrame
after Character.HumanoidRootPart
…
Yes Thank you this seems to work. However, I am having this issue where the welded part to the character doesn’t move with the character. Is there a way to fix this:
That is because the part is welded to the HumanoidRootPart, not the torso.
1 Like