Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How do I print the contents of a player?

Asked by 8 days ago

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)
0
You can use "unpack(array Table)" Ziffixture 5707 — 8d
0
for i = 1, #chr2 do print(chr2[i]) end TheBeastMare 2 — 7d

1 answer

Log in to vote
0
Answered by
Glacitron 147
8 days ago

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
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. 4thAxis 0 — 8d
0
Yeah my bad Glacitron 147 — 7d
Ad

Answer this question