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

Printing the content of a table?

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

✓ Accepted answer

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

1 comment

0

Sorry for the rushed post.

it is so ... simple ...

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

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