Both Players Die when Welded

Hello,
I am currently scripting some handcuffs. I am using a WeldConstraint to weld the characters together to do the detain. The problem is that when the detained person dies, so does the person who detained them. I have heard this is from the characters being welded together so they both die. Does anyone have some way to prevent this or something that acts like a weld that won’t kill both players when the detained one dies?

Things I’ve Tried

  • Using the .Died event when the detained person dies.
  • Storing the weld some where outside of the 2 characters.
  • Using any alternatives I could think of that may have acted like the WeldConstraints, regular welds and Motor6D’s.
  • Deleting the weld when the person dies.

Video

8 Likes

For killing the player, are you using :BreakJoins() or are you using Humanoid.Health = 0?

Also did you try breaking the weld before or after killing the player?

1 Like

The block puts the character’s health to 0 and to destroy the weld you would have to use the .Died event, which as I mentioned in my post, I already tried and it did not work because the character is already dead by the time it fires the event where you would delete the weld.

Thanks for that.

I used Character:BreakJoints() instead of setting the humanoid’s health to 0 and that worked. Could you try and use that method instead of setting the humanoid’s health to 0?

If that doesn’t work, could you try setting the Part0 and Part1 to the respective players’ HumanoidRootPart?

1 Like

BreakJoints() does make it where both don’t die but there will be guns in my game so it won’t work out that way unfortunately. Also Part0 and Part1 are already set to their HumanoidRootParts.

1 Like

I have to get off, but if you have any other solutions I could try please let me know and I will let you know if they work out.

1 Like

Couldn’t you use :BreakJoints when using the .Touched event is involved? Why would you need a weld while using guns?

1 Like

No matter if you use BreakJoints() or Health = 0. The only important thing is to set Part0 or Part1, to nil before apply the death.

@7z99 Is right. Why not on touch event, the Part0 or Part1 = nil line just before Health = 0 ?
Or just destroy the weld, you gonna create a new one when another guy is captured, isnt?

robloxapp-20210121-2138283.wmv (1.6 MB)

4 Likes

I believe try disabling Humanoid.BreakJointsOnDeath on death. This is because the humanoid when dying destroys all connections including the new weld to the player cuffing the other player which kills them, same goes for vehicles.

So yeah perhaps make a custom death event or disabling that property.

I believe this is why in some other games they use a heartbeat connection to psuedo CFrame weld the handcuffed person in order to avoid this issue.

5 Likes

Guns don’t use the .Touched event, they use raycasts then apply damage.

I would have to do that when the player dies, and the way the guns work is using raycasts then applying damage. The only way to detect that would be the .Died event which does not work because of it not firing in time.

Disabling BreakJointsOnDeath still kills the other player sadly. Might just have to go for CFrame type cuffs, but those don’t do movement as smoothly as welds.

Do you know how to make it where the CFrame is almost as smooth as a weld and doesn’t lag behind when moving? The Heartbeat connection makes it look jumpy and lag behind when moving.

I had this issue but it doesn’t just happens with this. It happens to all the Player is weld. I was riding an animal which had an Humanoid in. I reset my character and the animal died as well, I think because of the weld that the seat inserted. Idk what to do in this case though, just not use welds maybe?

2 Likes

What could I use instead of welds, is there something else that works like a weld?

Anchor the player and call SetPrimaryPartCFrame?

1 Like

Would that make it where the detained player would move as smooth as if they were welded?

I used AlignPosition and AlignOrientation, it works just like a weld and doesn’t kill both players. Thanks for all the responses though.

5 Likes

Having similar issues welding 2 players/NPCs together. Anyone have any solutions?

1 Like

There are a lot of posts about ‘carrying’ players and the physics involved. Try using the Search tool up top with the phrase carry other player npc

Also, did you try the Solution that @Icey_CD mentioned?

2 Likes