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
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.