In a script for my game, I defined a table by saying:
_G.Dead = {}
As you can see, its a global table and has no values in it yet. I connected the players humanoid to the died event and add their name to the table like this:
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) char.Humanoid.Died:Connect(function() for i, v in pairs(_G.Players) do if v == plr.Name then table.remove(_G.Players, i) -- Another table that actually works... table.insert(_G.Dead, v) end end end) end) end)
These scripts don't error out, the died function seems to have no trouble inserting a value into the table, but when I try to print "_G.Dead[1]", it says that I tried to define a nil value "_G.Dead". Thanks in advance for finding the error.
-Cmgtotalyawesome