Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Character died not removing player from table?

		repeat wait() until workspace.Values.Classic.Value == true --Waiting until the round starts
for i,z in pairs (_G.Playing) do --Getting the table 
	if z.Character.Humanoid then -- checking to make sure 'z' is a character
			z.Character.Humanoid.Died:connect(function(player) -- start if a character dies
				print(z.Character.Name..' has died') -- just saying the the character died
						table.remove(_G.Playing, i) -- not removing the player from the table?
						print(i,z)-- print the table to know that it removed..
			end)
	else
		return error('No player found in the table _G.Playing!') --ignore this this isnt a problem
			end
			end

I basically explained it in the table but this script is SUPPOSE to wait until a character died from the table _G.Playing then removes it so that another script can verify id the table only has 1 player, and yes i inserted the player into the table not the player's name..

1 answer

✓ Accepted answer

Your script is a working script my friend, I added a while true loop after this and made it print all the values in _G.Playing, when I first spawned in it was printing my name, when I died it no longer was printing my name. If you are looking for confirmation of this then run the following code in studio!

game.Players:WaitForChild("Player1")
_G.Playing = { game.Players.Player1 }

for i,z in pairs (_G.Playing) do --Getting the table 
    if z.Character.Humanoid then -- checking to make sure 'z' is a character
            z.Character.Humanoid.Died:connect(function(player) -- start if a character dies
                print(z.Character.Name..' has died') -- just saying the the character died
                        table.remove(_G.Playing, i) -- not removing the player from the table?
                        print(i,z)-- print the table to know that it removed..
            end)
    else
        return error('No player found in the table _G.Playing!') --ignore this this isnt a problem
            end
            end
coroutine.resume(coroutine.create((function() while wait() do for i,v in pairs(_G.Playing) do print(v.Name) end end end)))

This discussion is preserved as it was. New answers, comments, and votes are closed.