I've been working on a dueling arena for a bit and I've encountered a bit of an issue, a player queues, gets put into a duel (this function runs), after they complete their duel, I believe the .died event still fires so if at any point they die, their old duel partner will get respawned, aka the more duels they do the more .died events they're connected to.
function SETUP_DUEL(PLR1, PLR2) local ARENA for i,v in pairs (workspace.Arenas:GetChildren()) do if v:FindFirstChild("Occupied").Value == false then ARENA = v end end PLR1.Character.Died:Connect(function() --Code inside of here runs even after the player's done dueling. end) end
Attach the event to a variable
local connection connection = plr1.Character.Humanoid.Died:Connect(function() --do stuff connection:Disconnect() end)