Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

4 comments

0

What do the buttons need to do?

0

ill edit it

0

is there's any specific task the button needs to do or they're all the same?

0

they actually should give the object value of themself to a function

1 answer

✓ Accepted answer

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)

1 comment

0

Thank You!

This discussion is preserved as it was. New answers, comments, and votes are closed.