Welded Character Keeps Dying

I have been working on a skill in my game which requires two characters to be welded to a hitbox. Essentially, when the attacking player activates his skill, he lunges forward with a hitbox which is welded to him, and if the hitbox detects another character, it welds that character to the hitbox.

Video example:

As you can see in the above video, when the attacking player doesn’t die, it works perfectly fine and exactly as intended to.

Now, watch this:

This time, whenever the attacking player dies, so does the player being attacked. However, as shown in the video, this does not happen every time. I have tried everything, but these results prove to be inconsistent – so I cannot say for sure why sometimes the player dies, while other times the player doesn’t die.

Now, for those of you who will refer me to using Align Constraints, I have tried this. The attacking player moves too fast for the AlignPosition to keep up with. Yes, the network ownership of the victim player is set to the attacking player, and SetNetworkOwnershipAuto() is false for all parts of the victim player.

Here is a video using AlignPosition with MaxForce and Responsiveness as high as they can go (these results were much better than when RigidityEnabled was set to true):

Clearly, using Align Constraints is not a viable option unless there is something I’m missing.

Here is a snippet of my code which deals with the hitboxing and victim welding:

if hb.trapped.Value == "" then -- 'trapped' is a string value inside of the hitbox instance.
	local hits = workspace:GetPartsInPart(hb, charParams)
	if #hits ~= 0 then
		for _, h in pairs(hits) do
			if checkHumanoid(h) then
				local eChar = h:FindFirstAncestorWhichIsA("Model") -- eChar is the enemy/victim player
				if eChar:HasTag("Trapped") or eChar.Humanoid.Health <= 0 or eChar:HasTag("Ragdoll") or eChar:HasTag("Firing") then continue end -- if Character can't be trapped

				PowerPositioning:CheckNetworkOwner(Character, eChar) -- sets network owner to attacking player (disables automatically setting)
										
				eChar:AddTag("Trapped")
				hb.trapped.Value = eChar.Name -- hb is the hitbox instance
										
				task.spawn(function()
					local trapWeld = Instance.new("Weld", Character.Welds) -- Character is the attacking character
					trapWeld.Part0 = hb
					trapWeld.Part1 = eChar.HumanoidRootPart
					trapWeld.C1 = CFrame.new(0, 0, -1.5)*CFrame.Angles(0, math.pi, 0)
					trapWeld.Name = "ras_trap"
											
					local deathCon
					deathCon = Character.Humanoid.Died:Connect(function()
						hWeld.Part1 = nil -- hWeld is the weld connecting the hitbox to the attacking player
						trapWeld.Part1 = nil
						trapWeld:Destroy()
						deathCon:Disconnect()
						deathCon = nil
					end)
											
					task.delay(0.5, function() -- this is to test whether or not welded player dies. Debugging only.
						Character.Humanoid.Health = 0
					end)
											
					local eAnim: Animator = eChar.Humanoid:WaitForChild("Animator")
											
					for _, v in pairs(eAnim:GetPlayingAnimationTracks()) do
						v:Stop()
					end
											
					while eChar:HasTag("Trapped") do
						if not hb then break end
						if hb.Parent ~= workspace.FX then break end
						task.wait()
					end
											
					if deathCon then
						deathCon:Disconnect()
						deathCon = nil
					end

					PowerPositioning:ResetNetworkOwner(Character, eChar) -- resets network owner to default
					trapWeld:Destroy()
				end)
			end
		end
	end
end

This block is inside of a while loop which runs continously so long as “hb” exists, with only a task.wait() delay between loops.

If you have any suggestions, please let me know. If there is another way to go about this, I’m all ears.

Thank you for any help!

I made it so people are invincible during these frames, however, if they leave the game the same result happens. Is there any way around this??

Try messing around with root priority

Could be due to conflicting root priority with 2 humanoid root parts. Break joints on death should be false as well.

Theres always the CFrame option in renderstep if its just for clientside visuals.

1 Like

Break joints on death is disabled – and I will changing the Root Priority. Should I give the attacking player the higher root priority?

Nvm, perhaps it will give the victim the opportunity to the same to the attacker instead.

Id just recommend the CFrame solution instead.

That’s true, but wouldn’t that potentially cause a mismatch between the clients if their ping differential is too high?

Shouldnt happen if you do it individually on each clients simulation

2 Likes