Textbutton text not changing from script

Hi there, I’m trying to change the text of a textbutton inside a clone loop but the text doesn’t seem to change. When the line outside and before the clone loop, it changes but not inside.

local folder = game.ReplicatedStorage:WaitForChild("Tools")
local frame = script.Parent
local template = frame.shoptemplate
local button = template.Buy

template.Visible = false

for _, tool in pairs(folder:GetChildren()) do
	local newTemplate = template:Clone()
	newTemplate.Parent = frame
	newTemplate.Visible = true
	newTemplate.Name = tool.Name
	newTemplate.TextLabel.Text = tool.Name
	button.Text = "Test"
end

The button text you are changing is from the template not “NewTemplate”

That was a fairly simple solution. Thanks!

newTemplate.Text = tool.Name

Is newTemplate not the text label itself?

Yeah, it’s not the textlabel itself. Newtemplate is the actual frame with all the stuff inside it.

local folder = game.ReplicatedStorage:WaitForChild("Tools")
local frame = script.Parent
local template = frame.shoptemplate
local button = template.Buy
local zindex = button.ZIndex

template.Visible = false

for _, tool in pairs(folder:GetChildren()) do
	local newTemplate = template:Clone()
	newTemplate.Parent = frame
	newTemplate.Visible = true
	newTemplate.Name = tool.Name
	newTemplate.TextLabel.Text = tool.Name
	newTemplate.ZIndex = zindex + 1
	zindex += 1
	button.Text = "Test"
end

Then it’s because you’re cloning stuff on top of each other, you can set the ZIndex property to move instances on top/behind one another but ultimately you’ll need to reposition all of the created frames so that they don’t overlap and cover each other.

It is not, there’s a list layout under scrolling frame. The guy above already fixed the issue but I appreciate your effort!

Oh, your issue was regarding the text button not the cloned frame.