My Button duplicates

I want to make my crafting system.

The buttons duplicates itself who knows how many times. I see twice but it could be more

I am using a LocalScript and I am making a button with the name of the material there is only 3 materials in the folder and it makes 6 buttons.

local c = game.Lighting:WaitForChild("CraftingItems"):GetChildren()
for i=1,#c do
	local button = Instance.new("TextButton")
	button.Parent = CraftingFrame
	button.Size = UDim2.new(0.8,0,0.1,0)	
        button.Visible = true
	button.BackgroundColor3 = Color3.new(0,0,0)
	button.BorderColor3 = Color3.new(1,1,1)
	button.BorderSizePixel = 5
	button.Text = c[i].ItemName.Value
	button.TextColor3 = Color3.new(1,1,1)
	button.TextScaled = true
        button.Font = Enum.Font.Arcade
end

Is there exactly 3 items in the CraftingItems folder? or is there 6 items just 3 of them are materials.

EDIT: Still wondering about this because I tested out your script and it works fine for me.

There is only 3 inside of it :grinning_face_with_smiling_eyes:

I dont think your problem is anything to do with the script you provided

My personal suggestion is creating a template button, this would possibly fix your issue as Instance.new() can be a pain sometimes.

Create a template of what you are trying to make and follow your code again like so.

local cloned = -- cloned goes here
local c = game.Lighting:WaitForChild("CraftingItems"):GetChildren()
for i=1,#c do
	local button = cloned:Clone()
	button.Parent = CraftingFrame
	button.Size = UDim2.new(0.8,0,0.1,0)	
        button.Visible = true
	button.BackgroundColor3 = Color3.new(0,0,0)
	button.BorderColor3 = Color3.new(1,1,1)
	button.BorderSizePixel = 5
	button.Text = c[i].ItemName.Value
	button.TextColor3 = Color3.new(1,1,1)
	button.TextScaled = true
    button.Font = Enum.Font.Arcade
end

Does it make a difference if you create all the Properties first then put

at the end of the function?
Also try putting a print in the function loop to see how many times the function occurs.
And where is this script? From the section you’ve given us I think it’ll only run once due to the
first line stating what c is, then running the loop one time to collect the items in Lighting.
Why are you using Lighting, you should use ServerStorage or ReplicatedStorage.

I can’t test right now I will try later though!!!