Create buttons based on number of tools and change their name

Hello! I’m having yet another issue with my first foray into this kind of stuff.

I have the issue where I’m trying to make the same amount of buttons as the amount in a folder, and then change their names to the name of the tool itself. So far, this is my code.

function AddButtons()
	-- Declare variables
	local food = game.Lighting.helpr.Food
	local foodInList = food:GetChildren()
	local numberOfFood = #foodInList - 1
	
	-- Main code
	if numberOfFood == 0 then
		print("Error Code 01 - Missing Tools")
	else
		while numberOfFood > 0 do
			local button = script.Parent.ScrollingFrame.TextButton:Clone()
			button.Parent = script.Parent.ScrollingFrame
			numberOfFood = numberOfFood - 1
			for i, q in pairs(foodInList) do
				local text
				if q.Taken.Value == false then
					button.Text = tostring(q)
					print(q)
					q.Taken.Value = true
					end
				end
			end
		end
	end

AddButtons()

Any idea how to fix this?
Only one button has the text 6.

Well you only clone 1 button, so when you loop through the foodInList you are just change that same button’s text. Try:

function AddButtons()
	-- Declare variables
	local foodInList = food:GetChildren()
	local numberOfFood = #foodInList - 1
	
	-- Main code
	if numberOfFood == 0 then
		print("Error Code 01 - Missing Tools")
	else
		while numberOfFood > 0 do
			for i, q in pairs(foodInList) do
				local text
                local button = script.Parent.ScrollingFrame.TextButton:Clone()
	          	button.Parent = script.Parent.ScrollingFrame
		    	numberOfFood = numberOfFood - 1
				if q.Taken.Value == false then
					button.Text = tostring(q)
					print(q)
					q.Taken.Value = true
					end
				end
			end
		end
	end

AddButtons()