I don't know how clear I have to because of the title. But I am trying to do is when a player dies they are removed from a table. I did in fact get an error which was:
ServerScriptService.MainScript:68: invalid argument #2 to 'remove' (number expected, got Instance)
Here's my code.
--// Variables
local status = game.ReplicatedStorage:WaitForChild("Status")
local plrsLeft = game.ReplicatedStorage:WaitForChild("Players")
local timer = game.ReplicatedStorage:WaitForChild("Timer")
local platesWeClone = game.ServerStorage:WaitForChild("Plates")
local income = 5
local gameTime = 120
local intermissionTime = 10
--// Functions
local function SetTimer(op)
local minutes = math.floor(op/60)
local seconds = math.floor(op%60)
timer.Value = (string.format("%.2i:%.2i", minutes, seconds))
end
local function SetStatus(op)
status.Value = tostring(op)
end
local function SetPlrs(NumPlrsInTable)
plrsLeft.Value = tostring(NumPlrsInTable)
end
--// Loop
while true do
for i = intermissionTime,0,-1 do
SetTimer(i)
SetStatus("Intermission.")
SetPlrs(0)
local plrs = {}
wait(1)
if i == 0 then
for i,v in pairs(game.Players:GetPlayers()) do
if v then
table.insert(plrs,v)
end
end
SetStatus("Cleaning play area.")
wait(0.5)
game.Workspace.Plates:Destroy()
SetStatus("Play area cleaned, game starting soon!")
local newPlates = platesWeClone:Clone()
newPlates.Parent = workspace
for e = 5,0,-1 do
SetTimer(e)
wait(1)
if e == 0 then
SetStatus("Teleporting players to play area, do not move.")
for i,v in pairs(game.Players:GetPlayers()) do
if v then
local character = v.Character
local spawns = game.Workspace:FindFirstChild("SpawnPoints")
local AvailableSpawns = spawns:GetChildren()
if character:FindFirstChild("HumanoidRootPart") then
character:FindFirstChild("HumanoidRootPart").Anchored = true
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawns[1].CFrame + Vector3.new(0,5,0)
table.remove(AvailableSpawns,1)
end
wait(5)
character:FindFirstChild("HumanoidRootPart").Anchored = false
for o = gameTime,0,-1 do
SetTimer(o)
SetStatus("Game in progress.")
SetPlrs(#plrs)
wait(1)
for index, value in ipairs(plrs) do
if value == v.Name then -- trying to find the player name in the table
print(value .. " found at index " .. index) -- index will help remove the error because it was expecting a number, not an instance
for i, v in pairs(game.Players:GetPlayers()) do
if v then
local character = v.Character
character.Humanoid.Died:Connect(function()
table.remove(plrs, index)
end)
end
end
end
end
if o == 0 then
table.getn(plrs).Data.Money.Value = table.getn(plrs).Data.Money.Value + income
v:LoadCharacter()
end
end
end
end
end
end
end
end
end

2 comments
edited my answer.
Still not working.