WeldConstraint not working

So I’m trying to make a moving train by tweening its PrimaryPart which I’ve done before in the past. However, welding its descendants doesn’t seem to work via Welds or WeldCoinstraints. This causes only the PrimaryPart to move.

I am moving the model’s PrimaryPart with CFrame. I believe the problem lies within the weld script:

wait(1)
for _, v in pairs(script.Parent:GetDescendants()) do
	if v ~= script.Parent.PrimaryPart and v:IsA("BasePart") then
		local weld = Instance.new("WeldConstraint")
		weld.Part0 = v
		weld.Part1 = script.Parent.PrimaryPart
		weld.Parent = script.Parent.PrimaryPart
	end
end


me

Have you tried using Motor6Ds instead of welds? This is the only thing I can come up with without seeing the rest of the scripts but it’s worth a try as Motor6Ds are meant for animations and moving stuff.

Nope, didn’t work. Thanks for the suggestion though.

Try manually welding one of the parts in the model and then testing, if that works it’s something to do with your welding script, if not the problem lies somewhere else.

Also it could be that you should use ipairs() instead of pairs(). It’s worth a try

1 Like

Tried that, also didn’t work. But I fixed it by unanchoring all the parts I’m welding in the script. It’s all good now

3 Likes