Welds not working

hey again, back with more welding problems

this code down below does not want to weld stuff


script.Parent.Touched:Connect(function(touch)
	local model = touch.Parent
	local plr = game.Players:GetPlayerFromCharacter(model)
	local char = plr.Character
	local ragdoll = workspace[char.Name]
	local torso = ragdoll.Torso

	if char and not dbnc then
		dbnc = true	
		char.Humanoid.BreakJointsOnDeath = true
		char.Humanoid.Health = 0
		
		local head = blood:Clone()
		head.Parent = torso
		head.Position = torso.Position + Vector3.new(0,1,0)
		head.Orientation = Vector3.new(0,0,0)
		head.CanCollide = false
		
		local larm = blood:Clone()
		larm.Parent = torso
		larm.Position = torso.Position + Vector3.new(-1, 0.2, 0)
		larm.Orientation = Vector3.new(0,0,-270)
		larm.CanCollide = false
		
		local rarm = blood:Clone()
		rarm.Parent = torso
		rarm.Position = torso.Position + Vector3.new(1, 0.2, 0)
		rarm.Orientation = Vector3.new(0,0,-90)
		rarm.CanCollide = false
		
		local lleg = blood:Clone()
		lleg.Parent = torso
		lleg.Position = torso.Position + Vector3.new(-0.2, -1, 0)
		lleg.Orientation = Vector3.new(0,0,-180)
		lleg.CanCollide = false
		
		local rleg = blood:Clone()
		rleg.Parent = torso
		rleg.Position = torso.Position + Vector3.new(0.2, -1, 0)
		rleg.Orientation = Vector3.new(0,0,-180)
		rleg.CanCollide = false
		
		local weld1 = Instance.new("WeldConstraint")
		weld1.Parent = torso
		weld1.Part0 = torso
		weld1.Part1 = head
		
		local weld2 = Instance.new("WeldConstraint")
		weld2.Parent = torso
		weld2.Part0 = torso
		weld2.Part1 = larm
		
		local weld3 = Instance.new("WeldConstraint")
		weld3.Parent = torso
		weld3.Part0 = torso
		weld3.Part1 = lleg
		
		local weld4 = Instance.new("WeldConstraint")
		weld4.Parent = torso
		weld4.Part0 = torso
		weld4.Part1 = rarm
		
		local weld5 = Instance.new("WeldConstraint")
		weld5.Parent = torso
		weld5.Part0 = torso
		weld5.Part1 = rleg
		
		dbnc = false	
	
	end
end)

Yes, none of the parts are anchored.
Yes, the blood parts go to their required place
No, they do not stay there, they fall down.
Blood parts have their collisions off
and hell, i don’t know, im about to go insane

1 Like

Does the ragdoll object use R6 or R15? R6 would have a single “Torso” object and R15 should have a “UpperTorso” and a “LowerTorso” object. If you are using an R15 rig, try using those.

Alternatively, if that fails, have you tried using the HumanoidRootPart to connect the welds?

Yes, the ragdoll is R6. Nope, welding the parts to the HRP didn’t fix it.

You might want to check if the torso of the ragdoll is falling through the floor as well. I can’t see any problems with the welds themselves so far.
Are you also welding these from the client? Sometimes welds can act strangely client-side.

The torso does not fall down, and also it’s running on a serverside script.

Wait! I think I see the problem.

Specifically with the following code:

char.Humanoid.BreakJointsOnDeath = true
char.Humanoid.Health = 0

You are breaking the character model’s joints, this is probably creating unexpected behavior of ALSO breaking your own welds you declare later in the script. I think this happens because the Humanoid death event fires AFTER you create your welds.

Try doing this:


char.Humanoid.BreakJointsOnDeath = true
char.Humanoid.Health = 0
char.Humanoid.Died:Wait()
--Rest of code.

2 Likes

That did not work neither… I really don’t know what I did wrong here, the blood parts get cloned, get placed in correct places but they just don’t weld.

Try commenting out these and let me know if the welds still fail:

--char.Humanoid.BreakJointsOnDeath = true
--char.Humanoid.Health = 0
1 Like

Okay, it worked this time. And it looks like the problem is with the BreakJointsOnDeath property. But what can we do about it? My ragdoll script will not disable if I don’t turn on break joints, and turning it on breaks the welds.

Alright, we found the source of the problems.

Now, here is what we can do:

char.Humanoid.BreakJointsOnDeath = false
char.Humanoid.Health = 0
char.Humanoid.Died:Wait()

--Manually break the joints
char:BreakJoints()

--Your code...

--Should not break joints because we updated health earlier in the script and the death event already fired.
char.Humanoid.BreakJointsOnDeath = true


Edit: Whoops, forgot the wait for the event

The particle emitters disappear again.
Also here is the ragdoll script, it may be useful…

local hum = script.Parent:WaitForChild("Humanoid")

hum.BreakJointsOnDeath = false

hum.Died:Connect(function()
	
	hum.Parent.Torso.CanCollide = true
	hum.Parent.Head.CanCollide = true
	hum.Parent["Left Arm"].CanCollide = true
	hum.Parent["Left Leg"].CanCollide = true
	hum.Parent["Right Arm"].CanCollide = true
	hum.Parent["Right Leg"].CanCollide = true
	
	for index, joint in pairs(script.Parent:GetDescendants()) do
		
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint", joint.Parent)
			local a1 = Instance.new("Attachment", joint.Part0)
			local a2 = Instance.new("Attachment", joint.Part1)
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.LimitsEnabled = false
			socket.TwistLimitsEnabled = false
			joint:Destroy()
			
		end
		
	end
	
end)

edit: i got it from a youtube video since i dont know anything about joints, welds etc.

How odd! Tell me, what happens to the particle emitters when the joints break? Are they removed from the data model? Do they simply fall through the floor? Are they just not emitting particles anymore?

They just fall out of the map! As I said, the particle emitters get teleported to their places correctly and all of a sudden they just fall to the void! No traces of any sort of weld we created in the script.

Hm. Try commenting out this at the end of your code. Make sure BreakJointsOnDeath is false at the top.

--char.Humanoid.BreakJointsOnDeath = true

Let’s see if the manual BreakJoints() also breaks it

Manually breaking joints also breaks the welds. I also tried commenting the enabling breakjoints at the end, no difference.

When you update a position on a welded part, it all does not move together and causes the welds to break. It is suggested you use CFrame for all parts that are welded.

Uhhh… what exactly do you mean by that? Should I use CFrame to set the positions in the first place or use normal welds and set the c0 and c1 properties or something else??(im extremely sorry for my dumb questions, im really new to this stuff)

Use CFrame to set positions in the first place.

1 Like

Okay, it seems welds really bug out when a character dies with BreakJointsOnDeath.

The best thing to do is probably to disable BreakJointsOnDeath and not break the joints.

Alternatively, you could make the particle emitters CanCollide and just teleport them to where the broken limbs are.

1 Like

Thanks for the help everyone, I think I will go with a repeat loop to set the emitter positions.