Bug with WeldConstraint?

Hi so what i’m trying to achieve is that I want to make my little tank where my HumanoidRootPart is. I did the code but it results in this :

r

Code
-- SERVICES >--

local ss = game:GetService("ServerStorage")

----------------------------------------------

--< VARIABLES >--

local tanks = ss:WaitForChild("Tanks")

----------------------------------------------

--< CODE >--

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		
		local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
		local tankModel = tanks:FindFirstChild(player.Stats.Tank.Value):Clone()
		
		tankModel.Parent = character
		
		local weld1 = Instance.new("WeldConstraint")
		weld1.Parent = tankModel
		weld1.Part0 = tankModel:FindFirstChild("Cannon_Outline")
		weld1.Part1 = humanoidRootPart
		
		local weld2 = Instance.new("WeldConstraint")
		weld2.Parent = tankModel
		weld2.Part0 = tankModel:FindFirstChild("Cannon")
		weld2.Part1 = humanoidRootPart
		
		local weld3 = Instance.new("WeldConstraint")
		weld3.Parent = tankModel
		weld3.Part0 = tankModel:FindFirstChild("Main_Outline")
		weld3.Part1 = humanoidRootPart
		
		local weld4 = Instance.new("WeldConstraint")
		weld4.Parent = tankModel
		weld4.Part0 = tankModel:FindFirstChild("Main")
		weld4.Part1 = humanoidRootPart
		
	end)
end)

The tank is welded to my HumanoidRootPart but it’s not in the right position.
Any idea of why this is happening?

That’s not a bug. All is ok with weld constrait.
You should to change position of tank before welding it with weld constrait or you can just use simple weld.
I would suggest doing this before welding.

tankModel.PrimaryPart = tankModel:FindFirstChild("Main")
tankModel:SetPrimaryPartCFrame(humanoidRootPart.CFrame)
1 Like

Your tank is never placed to the player’s position. Consider using tankModel:PivotTo() and putting in the player’s character cframe with only the y rotation.

Note: kercig’s solution can still work, it just uses an older method.

1 Like

It worked, thanks!

Here is the result :
image

Also thanks to @BilonGamer for helping

1 Like