Lets say I have a table.
local Table = {}
GUI1.MouseButton1Down:Connect(function()
table.insert(Table, GUI1.TextLabel.Text)
end)
This script does the job of adding an item to that table when a GUI is clicked.
GUI1.MouseButton1Down:Connect(function()
table.insert(Table, GUI1.TextLabel.Text)
end)
GUI2.MouseButton1Down:Connect(function()
table.insert(Table, GUI2.TextLabel.Text)
end)
GUI3.MouseButton1Down:Connect(function()
table.insert(Table, GUI3.TextLabel.Text)
end)
GUI4.MouseButton1Down:Connect(function()
table.insert(Table, GUI4.TextLabel.Text)
end)
This script also does the job, but it is long.
What im asking is, is there a way to shorten the script above ?
I have LOTS of GUIs that can be clicked and can add an item to the table. Copy pasting that funciton over and over again will make the script atleast 600 lines long, not counting the other code in the script. So this isn’t an option. I tried searching for something that might help but I didn’t find anything.
I was originally thinking I can find out which GUI was clicked, and connect each GUI to a function. But I’m not too sure I can do that.
If it is possible to see which GUI was clicked, it could solve the script. If anybody knows a solution, please help !
Thanks for your time !