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

How do I print the contents of a player?

I was trying to make a simple script to print the contents of a player's character:

local chr1 = game.Players.LocalPlayer.Character
local chr2 = chr1:GetChildren()

print(chr2)

2 comments

0

You can use "unpack(array Table)"

0

for i = 1, #chr2 do print(chr2[i]) end

1 answer

✓ Accepted answer

You can use this script, basically you want to loop through all the contents and print each one individually you can't just print a table,

local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()

for i , v in pairs(Char:GetChildren()) do --Char:GetDescendants() if you want to get all of them 
	print(v.Name)
end

2 comments

0

I'd like to advise you to use ipairs instead, instances serve as number-type references to tables so we can perfectly use ipairs here. In the current version of lua roblox uses ipairs is generally faster then pairs. Its just good practice as pairs usually shows that the object your traversing through has non-numeric indices.

0

Yeah my bad

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