Impossible to assign Part0 of WeldContraint

I’m trying to weld a simple weapon to the LeftHand of the character, but it doesn’t assign Part0 of WeldConstraint at all. I tried many different ways to assign it, but it just never works. It even prints “LeftHand”, which shows that the character is loaded…


Weapon is a model that has a PrimaryPart. The PrimaryPart is that transparent block, which is a duplicate of the character’s LeftHand
image


Here’s my code

local Weapon = SS:WaitForChild("Weapons"):WaitForChild(i):Clone()
local WeldTo = Player.Character:WaitForChild("LeftHand")
Weapon.Parent = Player.Character
print("Welding Weapon to "..WeldTo.Name) -- prints "LeftHand"
local Weld = Instance.new("WeldConstraint", Weapon.PrimaryPart)
Weld.Part0 = WeldTo -- Somehow doesn't assign Part0
Weld.Part1 = Weapon.PrimaryPart
Weapon:PivotTo(WeldTo.CFrame)

Here are the properties of the Parts inside Weapon model
image
image


Does anyone know why it’s not welding the model?

1 Like

set the parent of the WeldConstraint after you’ve positioned it and set the properties

local Weapon = SS:WaitForChild("Weapons"):WaitForChild(i):Clone()
local WeldTo = Player.Character:WaitForChild("LeftHand")
Weapon.Parent = Player.Character
print("Welding Weapon to "..WeldTo.Name) -- prints "LeftHand"
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = WeldTo
Weld.Part1 = Weapon.PrimaryPart
Weapon:PivotTo(WeldTo.CFrame)
Weld.Parent = Weapon.PrimaryPart --set the parent here
1 Like

Still doesn’t assign Part0

have you tried setting Part0 after changing cframe of weapon?

btw if u want to animate that weapon consider using Motor6D over weld. (Motor6D also doesn’t require you to set cframe of weapon)

1 Like

Hello, You can try this. If you have any questions make sure you ask.

--|< Variables >|--
local Weapon = SS:WaitForChild("Weapons"):WaitForChild(i):Clone();
local WeldTo = Player.Character:WaitForChild("LeftHand");

--|< Main >|--
Weapon.Parent = Player.Character;
print(`Welding Weapon to {WeldTo.Name}.`);

local Weld = Instance.new("WeldConstraint", Weapon.PrimaryPart or Weapon.Handle);
Weld.Part0 = WeldTo;
Weld.Part1 = Weapon.PrimaryPart or Weapon.Handle;
Weapon:PivotTo(WeldTo.CFrame);
1 Like

This is so weird bruh…
It’s a server script, but it only works in Client???


Doesn’t change anything, I’ll try Motor6D if I can’t fix it

have u tried manually setting, does it work when you manually set Part0 to LeftHand of player? (I am trying to understand if this is a coding related or constraint)

1 Like

It does work, but it doesn’t move the model to the LeftHand cframe. Even if I do it with the command
workspace.KrxKenDev.Weapon:SetPrimaryPartCFrame(workspace.KrxKenDev.LeftHand.CFrame)

I tried to replicate the issue with the code you gave but it did set Part0, I had to move

this line to above

and it fixed the issue where cframe wasn’t applying to it.

here is place file u can try to replicate it to your own project.
sword-welding.rbxl (56.4 KB)

1 Like

Nevermind I fixed it, it was because of task.spawn apparently.
Thanks a lot of helping! I gave you the solution mark.

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