Why is it not adding?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to add the index the same as the varible in a table

  2. What is the issue? Include screenshots / videos if possible!
    The issue is it is not adding the varible This is what it says:
    image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked in the Developer Hub, I reseted Studio, and I printed words to see if it words but It doesn’t for some reason.

Please Help

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local FrameTable = {}
local ScrollingTable = {}
local TextLabelTable = {}
local TextButtonTable = {}
local TextBoxTable = {}
local ImageButtonTable = {}
local ImageLabelTable = {}
local VideoFrame = {}



for i,v in pairs(Add:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			local object = Instance.new(v.Name)
			if object then
				if object:IsA("TextButton") then
					object.Size = UDim2.new(0.146, 0,0.065, 0)
					
				elseif object:IsA("TextBox") then
					object.Size = UDim2.new(0.146, 0,0.065, 0)
				elseif object:IsA("TextLabel") then
					object.Size = UDim2.new(0.146, 0,0.065, 0)
				elseif object:IsA("ImageButton") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif  object:IsA("ImageLabel") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif  object:IsA("Frame") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif object:IsA("ScrollingFrame") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif object:IsA("VideoFrame") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				end
					
				object.Parent = Main
				object.Visible = true
				object.Position = UDim2.new(.5,0,.5,0)
				object.BackgroundColor3 = Color3.new(1,0,0)
				
				

			end
		end)
	end
end

local SizeFrame = Properties.SizeFrame

local sizexframe = SizeFrame.X
local sizeyframe = SizeFrame.Y

local sizeXoffset = sizexframe.Offset
local sizeXscale = sizexframe.Scale

local sizeYoffset = sizeyframe.Offset
local sizeYscale = sizeyframe.Scale




Main.ChildAdded:Connect(function(object)
	print(object.ClassName)
	if object:IsA("TextButton") then
		print("Adding Button To Table")
		print(TextButtonTable)
		for _,v in pairs(TextButtonTable) do
			
			print("Adding Button To Table 2")
			table.insert(TextButtonTable,_)
		end
		
		
	elseif object:IsA("TextBox") then
		
	elseif object:IsA("TextLabel") then
	
	elseif object:IsA("ImageButton") then
	
	elseif  object:IsA("ImageLabel") then
	
	elseif  object:IsA("Frame") then
		
	elseif object:IsA("ScrollingFrame") then
		
	elseif object:IsA("VideoFrame") then
			
	end

	
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I think that you’re looping through TextButtonTable Even there’re no values

but its a new table. I need a new table to do what I want to do

But you can’t loop through a table without values

Don’t you need 3 arguments for this:

table.insert(TextButtonTable,_)

No, 2 arguments just puts the entry at the end of the table.

It wont print(“Adding Button To Table 2”) though

Did you mean to loop through the TextButtonTable then insert _ into TextButtonTable or is that the mistake?

Yes I meant to do that. I added a TestTable and it freezes roblox studio for some reason…
heres the script:

local Add = script.Parent.Add
local Properties = script.Parent.PropertiesFrame
local Items = script.Parent.ItemsFrame
local Exit = script.Parent.X

local FrameTable = {}
local ScrollingTable = {}
local TextLabelTable = {}
local TextButtonTable = {}
local TextBoxTable = {}
local ImageButtonTable = {}
local ImageLabelTable = {}
local VideoFrameTable = {}

local TestTable = {"Test","Test2"}


for i,v in pairs(Add:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			local object = Instance.new(v.Name)
			if object then
				if object:IsA("TextButton") then
					object.Size = UDim2.new(0.146, 0,0.065, 0)
					
				elseif object:IsA("TextBox") then
					object.Size = UDim2.new(0.146, 0,0.065, 0)
				elseif object:IsA("TextLabel") then
					object.Size = UDim2.new(0.146, 0,0.065, 0)
				elseif object:IsA("ImageButton") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif  object:IsA("ImageLabel") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif  object:IsA("Frame") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif object:IsA("ScrollingFrame") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				elseif object:IsA("VideoFrame") then
					object.Size = UDim2.new(0.073, 0,0.13, 0)	
				end
					
				object.Parent = Main
				object.Visible = true
				object.Position = UDim2.new(.5,0,.5,0)
				object.BackgroundColor3 = Color3.new(1,0,0)
				
				

			end
		end)
	end
end

local SizeFrame = Properties.SizeFrame

local sizexframe = SizeFrame.X
local sizeyframe = SizeFrame.Y

local sizeXoffset = sizexframe.Offset
local sizeXscale = sizexframe.Scale

local sizeYoffset = sizeyframe.Offset
local sizeYscale = sizeyframe.Scale




Main.ChildAdded:Connect(function(object)
	print(object.ClassName)
	if object:IsA("TextButton") then
		print("Adding Button To Table")
		print(TextButtonTable)
	
		for _,v in pairs(TestTable) do
			

			print("Adding Button To Table 2")
			table.insert(TestTable,_)
			print(TestTable)
		end
	elseif object:IsA("TextBox") then
		
	elseif object:IsA("TextLabel") then
	
	elseif object:IsA("ImageButton") then
	
	elseif  object:IsA("ImageLabel") then
	
	elseif  object:IsA("Frame") then
		
	elseif object:IsA("ScrollingFrame") then
		
	elseif object:IsA("VideoFrame") then
			
	end

	
end)

Wouldn’t “_” be a number and v will be whatever you are inserting? Change it to

	for _,v in pairs(TestTable) do
			

			print("Adding Button To Table 2")
			table.insert(TestTable, v)
			print(TestTable)
		end

It still doesn’t print “Adding Button To Table 2” I think this is a glitch

You can’t loop through a table without values

1 Like
local TestTable = {}

for i, v in pairs(TestTable) do
      print(i.."."..v) -- It won't print nothing
end
1 Like

yes but it is a glitch with your code, not roblox’s