Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Printing the content of a table?

Asked by 9 years ago

I have a script that adds to the table, but what I'm trying to do is that every 10 seconds, it will print out the contents.

01local deadPlayers = {}
02game:GetService('Players').PlayerAdded:connect(function(player) --To add the information
03    player.CharacterAdded:connect(function(character)
04        character:WaitForChild("Humanoid").Died:connect(function()
05            table.insert(deadPlayers, player.Name)
06            print(player.Name)
07        end)
08    end)
09end)
10 
11while wait(10) do
12    print(#deadPlayers:GetFullName()) --Extracted from http://wiki.roblox.com/index.php?title=Table#Reading_from_and_writing_to_arrays
13end

But I don't know how to fix it.

My error

121:04:48.821 - ServerScriptService.Script:12: attempt to call method 'GetFullName' (a nil value)
221:04:48.823 - Stack Begin
321:04:48.825 - Script 'ServerScriptService.Script', Line 12
421:04:48.827 - Stack End

2 answers

Log in to vote
0
Answered by 9 years ago

while true do for i = 1, #deadPlayers do print(deadPlayers[i]) end wait(10) end

0
Sorry for the rushed post. jordan0810 55 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

it is so ... simple ...

1local deadPlayers = {}
2print(unpack(deadPlayers))

Answer this question