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)
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)
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
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.
Yeah my bad
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
You can use "unpack(array Table)"
for i = 1, #chr2 do print(chr2[i]) end