Table Dump not working

Hi!
This one is pretty stupid to be honest, but I’m trying to get better with Tables, so I made this, but the Print isn’t working.
What’s wrong?
Thanks!

local folder = game.Players.LocalPlayer.PlayerGui
local imageIds = {}
local buttonsText = {}
local buttonsNames = {}
local imageNames = {}
local Text = {}
local LabelNames = {}
local boxtext = {}


script.Parent.MouseButton1Click:Connect(function()
	for i, v in pairs(folder:GetChildren()) do
		if v:IsA("ImageLabel") or v:IsA("ImageButton") then
			table.insert(imageIds, v.Image)
			table.insert(imageNames, v.Name)
		elseif v:IsA("TextButton")  then
			table.insert(buttonsText, v.Text)
			table.insert(buttonsNames, v.Name)
		elseif v:IsA("TextLabel")  then
			table.insert(Text, v.Text)
			table.insert(LabelNames, v.Name)
		elseif v:IsA("TextBox")  then
			table.insert(boxtext, v.Text)
		end
	end
	warn("⚠️⚠️⚠️StarterGui dump info is below!⚠️⚠️⚠️")
	print("Image Names")
	for i, v in pairs(imageNames) do
		print(i, v)
	end
	print("Image ID's")
	for i, v in pairs(imageIds) do
		print(i, v)
	end
	print("Button Text")
	for i, v in pairs(buttonsText) do
		print(i, v)
	end
	print("Button Names")
	for i, v in pairs(buttonsNames) do
		print(i, v)
	end
	print("Text")
	for i, v in pairs(Text) do
		print(i, v)
	end
	print("Text Names")
	for i, v in pairs(LabelNames) do
		print(i, v)
	end
	print("Textbox Text")
	for i, v in pairs(boxtext) do
		print(i, v)
	end
	script.Parent.Parent.data.Visible = true

end)

You should probably add :WaitForChild():

local folder = game.Players.LocalPlayer:WaitForChild("PlayerGui")

Use :GetDescendants(), instead of :GetChildren():

for i, v in pairs(folder:GetDescendants()) do

Full edit:

local folder = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local imageIds = {}
local buttonsText = {}
local buttonsNames = {}
local imageNames = {}
local Text = {}
local LabelNames = {}
local boxtext = {}


script.Parent.MouseButton1Click:Connect(function()
	for i, v in pairs(folder:GetDescendants()) do
		if v:IsA("ImageLabel") or v:IsA("ImageButton") then
			table.insert(imageIds, v.Image)
			table.insert(imageNames, v.Name)
		elseif v:IsA("TextButton")  then
			table.insert(buttonsText, v.Text)
			table.insert(buttonsNames, v.Name)
		elseif v:IsA("TextLabel")  then
			table.insert(Text, v.Text)
			table.insert(LabelNames, v.Name)
		elseif v:IsA("TextBox")  then
			table.insert(boxtext, v.Text)
		end
	end
	warn("⚠️⚠️⚠️StarterGui dump info is below!⚠️⚠️⚠️")
	print("Image Names")
	for i, v in pairs(imageNames) do
		print(i, v)
	end
	print("Image ID's")
	for i, v in pairs(imageIds) do
		print(i, v)
	end
	print("Button Text")
	for i, v in pairs(buttonsText) do
		print(i, v)
	end
	print("Button Names")
	for i, v in pairs(buttonsNames) do
		print(i, v)
	end
	print("Text")
	for i, v in pairs(Text) do
		print(i, v)
	end
	print("Text Names")
	for i, v in pairs(LabelNames) do
		print(i, v)
	end
	print("Textbox Text")
	for i, v in pairs(boxtext) do
		print(i, v)
	end
	script.Parent.Parent.data.Visible = true
end)

There are objects called ScreenGui’s which clone to the PlayerGui from StarterGui, when a player joins. You should you use :GetDescendants() instead of :GetChildren(), for that reason and many other reasons.

1 Like

In what way is the print not working? What’s your output?

Depends, “GetChildren()” is faster, if only the children of the referenced instance are required, otherwise use “GetDescendants()”.