Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I efficiently add infinite button GUI's with their own events?

Asked by
Nootian 184
4 years ago
Edited 4 years ago

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()

0
What do the buttons need to do? IvanJupiter 36 — 4y
0
ill edit it Nootian 184 — 4y
0
is there's any specific task the button needs to do or they're all the same? Is_Hunter 152 — 4y
0
they actually should give the object value of themself to a function Nootian 184 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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)
0
Thank You! Nootian 184 — 4y
Ad

Answer this question