I have a ScrollingFrame Ui with dozens of Image buttons that each have a local script in them that sets a StringValue’s value to the name of the button (All have different distinct names). I’ve been coding with UI for a bit now and have never learned a way to simplify this to one script. I’m aware it’s most likely bad practice as having all these local scripts is unnecessary. I’m going to guess the solution is some sort of module script but could someone give me an outline of the correct method?
ok so do a for loop like
for i,image in pairs(yourScrollingFrame:GetChildren()) do
image.MouseButton1Click():Connect(function()
-- do what you want in all the local scripts
end
end
Thank you. This must be obvious but I had no idea a function could be called from a for loop. I’ll have to look into more applications for this.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.