Hello, how would i make this table readable: table: 0x4069ce12cfa35ff4
table.foreach(YOUR_TABLE, print)
In studio it automatically makes the table unpacked
In the output bar, there is 3 dots(top left) , which upon clicking will show some options. Under that, find Log Mode and disable it.
It wont print anything, even if i try to print it after the table.foreach
Now it just prints {}. just that
Becausr ur table is empty, that is the only reason for it.
There is data in the table, the value of a leaderstat
Could you show me the code along with the line in which u print the table?
This is the Code:
function GetStats()
for _,v in next,Players:GetChildren() do
for _,c in next,v:WaitForChild("leaderstats"):GetChildren() do
if c:IsA("NumberValue") then
local cc = c:GetChildren()
print(cc)--were i print the table
end
end
end
end
Simple enough cc doesn’t have children
It dose, C is getting all of the NumberValues in the leaderstats folder
Im sry, I meant to say cc doesn’t have any children
Yes, That’s true, so do i just print C?
Well, your printing it so u shud decide
You’re printing the children of each number value, which would probably be nothing.
Try something like this if you want a table of player stats:
function GetStats()
local data = {}
for _, player in ipairs(game.Players:GetPlayers()) do
local pdata = {}
for _, leaderstat in ipairs(player.leaderstats:GetChildren()) do
pdata[leaderstat.Name] = leaderstat.Value
end
data[player.Name] = pdata
end
end
The table would be structured like this:
{
["MasonX890"] = {
["Money"] = 5200,
["Points"] = 25,
["Whatever"] = "stuff"
}
}
To print it you would have to iterate through like this::
function printData(data)
for player, stats in pairs(data) do
print(player)
for statName, statValue in pairs(stats) do
print("\t", statName, ":", statValue)
end
end
end
local function printTableRecursive(t, c)
c = c or {}
if not c[t] then
c[t] = true
for index, value in pairs(t) do
if type(index) == "table" then
printTableRecursive(index, c)
else
print(index)
end
if type(value) == "table" then
printTableRecursive(value, c)
else
print(value)
end
end
end
end
printTableRecursive({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {["a"] = true, ["b"] = true, ["c"] = true}, {[true] = {0}}})