Welds being modified for no reason

Hi! I was building a tank, it works pretty fine and it’s welds are in the correct position, it looks like this:


Now, instead of runing the game I played it as a player and this happened:

I would appreciate any help!

1 Like

Do the barrels / turret have a cframe animation or a script ? Do you use a plugin to weld all parts together ?

I welded it manually to the head.

So it acts like a webbing or a 3d “cloth” ? Or is it a tool ? If it’s a cloth, I have maybe the solution for that. By a cloth, I mean several parts attached to an Humanoid.

It will follow the player like an accessory.

image

They are just parts, not clothes nor tools

When I mean it acts like a cloth, it act like an accessory. The whole model welds to the humanoid head/body, and move with the character. That’s maybe what you are doing. For this, I suggest you to make a simple group named as you want. That will be the root of your tank model. You will have a group with different parts in.

image

After that, you make another group of the group. You will see why a bit later. It will be the root of the “accessory”. Give the name you want to it, it doesn’t matter. Insert inside this root an Humanoid. You should have something like that.

image

Into the “Tank” group (The root group of your model, not accessory), you will bring a part called “Middle”. In this part, you insert a SpecialMesh by clicking on the little “+” next to the “Middle” part.

image

Click on the “Mesh” then look at your properties. The Meshtype can be head (if you want to weld it to your head) or torso. Depends on where you want to weld your model.

Finally, you insert a part to equip on touch your model. This part must be inside the “Accessory” group root. Not inside your model’s group. You insert a script inside. I called it “Hat”.

image

Insert the following code into your script ;

function onTouched(hit)
	local d = hit.Parent:GetChildren() -- start of hat remover
	for i=1, #d do 
		if (d[i].className == "TheGroup") then 
			d[i]:remove() 
		end 
	end	-- end of hat remover
	if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("TheGroup") == nil then
		local g = script.Parent.Parent.TheGroup:clone()
		g.Parent = hit.Parent
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].className == "Part" or "Unionoperation" then
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
				g.Middle.Transparency = 1
			end
				local Y = Instance.new("Weld")
				Y.Part0 = hit.Parent.Head
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
		
	end
end

script.Parent.Touched:connect(onTouched)

Dont forget to replace all “TheGroup” by the name of the group that contain the model. If you named the group that contains all tank parts “tank”, replace all “TheGroup” by tank".

Hope that I helped you a lot.

I have fixed it on my own! Instead of using normal welds I used WeldConstraints, thanks anyways!

1 Like