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 7 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.

local deadPlayers = {}
game:GetService('Players').PlayerAdded:connect(function(player) --To add the information
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            table.insert(deadPlayers, player.Name)
            print(player.Name)
        end)
    end)
end)

while wait(10) do
    print(#deadPlayers:GetFullName()) --Extracted from http://wiki.roblox.com/index.php?title=Table#Reading_from_and_writing_to_arrays
end

But I don't know how to fix it.

My error

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

2 answers

Log in to vote
0
Answered by 7 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 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

it is so ... simple ...

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

Answer this question