# Determining when either player dies in a duel

I’m attempting to wait for two people to die in the dueling game.
My real blunder here is the fact I’m having trouble trying to determine when either player dies and I need to respawn them. This is what I have so far…
(Yes, this is probably re-stated crappy logic that will ultimately look horrible, but it works.)

``````local wdueler1 = work[Participant1]
local wdueler2 = work[Participant2]
local pdueler1 = Players:FindFirstChild(Participant1)
local pdueler2 = Players:FindFirstChild(Participant2)
wdueler1.Humanoid.Torso.CFrame = work.Duel1_1.CFrame
wdueler2.Humanoid.Torso.CFrame = work.Duel1_2.CFrame
swordtool.Parent = pdueler1.Backpack
swordtool2.Parent = pdueler2.Backpack

if wdueler1.Humanoid.Health <= 0 or wdueler2.Humanoid.Health <= 0 then
table.remove(Dueling, Dueling[1])
table.remove(Dueling, Dueling[1])
end
end
``````

I gave the top bit to make sure people get the context. If anyone have some logic improvements for my re-used statements, they are gratefully appreciated although I am focused on determining when either player dies to remove them from Dueling table and respawning them.

EDIT : The reason I had to separate the workspace participant from player participant is due to I was having their strings in a table, so I thought it was the only way to find those.

Have you tried using a folder or value to find out if the player is in a duel? Try inserting a value when the player enters the duel and deleting that value after the duel.

That isn’t the probably, I’m trying to determine when they die. like with their health or such.

use the:

``````wdueler1.Humanoid.Died:connect(function()
table.remove(Dueling, Dueling[1])
table.remove(Dueling, Dueling[1])
end)
``````

Have you tried the humanoid.died function?

Make a folder anywhere, i would recommend ReplicatedStorage because both client & server can access it

When the 2 players go in the duel, add them both using values in the ReplicatedStorage, example:

``````local Value = Instance.new("StringValue",game.ReplicatedStorage.Players)
Value.Name = plr.Name -- duellers name
``````

Use the humanoid.Died event to check once a player has died.

When this happens, you need to check if their name is in the folder, example:
if plr.Name == Value.Name then
– do stuff
end