How to remove players on death from my currentplayers table for a minigame

hello all, I’ trying to start basic with scripting so I’m trying to make a minigame that simply teleports the currentPlayers at the beginning of the game, and when they die it knocks them out of the table and when there is only one player left, they get an award like +1 win. How do I remove a player out of the table though, because if they die at a random pace I won’t be able to index them properly as they get moved around in the table. Can someone explain this to me please I am a little lost.

Example of removing something out of a table

--Make table
local aliveplayers = {"SPR1NG3R","wf_sh"}

--Remove SPR1NG3R from table
table.remove(aliveplayers,table.find(aliveplayers,"SPR1NG3R"))

--Print the table
for i,v in pairs(aliveplayers) do
	print(i,v)
end

image

Oh sweet dude! I was looking at table.find but I was under the impression it didn’t return the index. Thanks though that is super helpful!


table.find’s purpose is for finding if something exists in a table, and returns the index its at

1 Like