By infinite buttons, I mean it can be any max amount, right now I put individual scripts into each button GUI, and they all connect into an event. How would I do it without scripts, because I am trying to make a plugin, which can only handle one. Here is the base code:
MakeRandom = Random.new() Folder = workspace.Buttons CloneButton = workspace.CloneButton for ButtonNumber = 1,MakeRandom:NextInteger(0,100) do ClonedButton = CloneButton:Clone() ClonedButton.Parent = Folder ClonedButton.Name = "Button_"..ButtonNumber end function Print(ObjectValue) print("yay!") print("we did it!") print(ObjectValue.Name) end --Each button has: "Button_5" or "Button_6" for ease, or you can use in pairs
The buttons go into the function: Print()
Aslong as you reapeat the pattern and change the number you can make that button do anything an infinite amount of time.
CODE:
local BUTTONNUMBER = 1 local BUTTON = script.Parent.TextButton.Name BUTTON = BUTTONNUMBER function OnClicked() BUTTONNUMBER = BUTTONNUMBER + 1 print(BUTTONNUMBER) end script.Parent.TextButton.MouseButton1Down:connect(OnClicked) function OnClicked() if BUTTONNUMBER == 1 then print("Do whatever the 1st time round") -- insert script here end if BUTTONNUMBER == 2 then print("Do whatever the 2nd time round") -- insert script here end if BUTTONNUMBER == 3 then print("Do whatever the 3rd time round") -- insert script here end --keep repeating the pattern for however much thing you want end script.Parent.TextButton.MouseButton1Down:connect(OnClicked)