Hey scripters who know what they’re doing (me not being one of them!) - I’m trying to create a system that adds a new button into a ScrollingFrame for each instance in an array. I have a folder with all of the instances inside of my games Lighting folder, and I load them into my script using :GetChildren. For some reason, it doesn’t seem to do anything when I spawn in.
My current script looks like this:
local serveitems = game.Lighting.ServeItems:GetChildren()
local scrollframe = script.Parent
local buttontoclone = scrollframe.placeholder
local scripttoclone = scrollframe.setvaluescript
for i = 1, #serveitems do
if i == 1 then
local currentbutton = serveitems[i]
local newbutton = buttontoclone:Clone()
local newscript = scripttoclone:Clone()
newscript.Parent = newbutton
newbutton.Name = currentbutton.Name
newbutton.Text = currentbutton.Name
newbutton.Visible = true
else
local currentbutton = serveitems[i]
local lastbutton = serveitems[i-1]
local newbutton = buttontoclone:Clone()
local newscript = scripttoclone:Clone()
newscript.Parent = newbutton
newbutton.Name = currentbutton.Name
newbutton.Text = currentbutton.Name
newbutton.Visible = true
local actuallastbutton = scrollframe:WaitForChild(lastbutton.Name)
newbutton.Position.Y = actuallastbutton.Position.Y + {0.044, 0}
end
end
A screenshot of the explorer tab just to help:
I’ve given a few other posts a read on the DevForum, but couldn’t find anything to help me with this particular issue.
No errors print out in the Output.
I don’t know if I’ve just made a rookie error here, or if this is something that just isn’t possible, but any help you can give me would be much appreciated!
Thanks,
Kent