Jump to content

Random GUI generator


Guest QuantumxGeneral

Recommended Posts

  • 3 weeks later...

Simply put all the GUIs in a folder, then use the Random object to get a number between 1 and the number of GUIs. After you have the number, use folderPath[number] to get a random GUI. Hope this helped. 

Edited by CloudRider

Share this post


Link to post
Share on other sites
  • 3 weeks later...

You could have a folder with all the GUIs in it like cloud said and then have a for loop and put them all in a table like this

local guis = game.ServerStorage.guis --The gui folder containing the guis

local guiTable = {} --The gui table

 

for i,v in pairs(guis:GetChildren()) do --The for loop that inserts all the guis in the guis folder into the guyi table

table.insert(guiTable, #guiTable+1, v)

end

 

local guiSelection = math.random(1,#guiTable) --Randomly selects a item from the table's index in it

local guiSelected = guiTable[guiSelection] --Gets the randomly selected item via the index that was randomly selected above

print(guiSelected.Name)

 

And then you can just put more guis in the folder (not with the same names of course) and it will automatically select one

Edited by kom297
Adding more information
  • Downvote 1

Share this post


Link to post
Share on other sites
4 minutes ago, kom297 said:

You could have a folder with all the GUIs in it like cloud said and then have a for loop and put them all in a table like this

local guis = game.ServerStorage.guis --The gui folder containing the guis

local guiTable = {} --The gui table

 

for i,v in pairs(guis:GetChildren()) do --The for loop that inserts all the guis in the guis folder into the guyi table

table.insert(guiTable, #guiTable+1, v)

end

 

local guiSelection = math.random(1,#guiTable) --Randomly selects a item from the table's index in it

local guiSelected = guiTable[guiSelection] --Gets the randomly selected item via the index that was randomly selected above

print(guiSelected.Name)

 

And then you can just put more guis in the folder (not with the same names of course) and it will automatically select one

This would work too but there isn't any reason to put them in a table, since the :GetChildren() method already return a table with all the elements in the folder. 

  • Upvote 1

Share this post


Link to post
Share on other sites
39 minutes ago, CloudRider said:

This would work too but there isn't any reason to put them in a table, since the :GetChildren() method already return a table with all the elements in the folder. 

Fair enough i just didn't think of that really at the time

  • Downvote 1

Share this post


Link to post
Share on other sites
On 5/30/2020 at 2:36 PM, kom297 said:

You could have a folder with all the GUIs in it like cloud said and then have a for loop and put them all in a table like this

local guis = game.ServerStorage.guis --The gui folder containing the guis

local guiTable = {} --The gui table

 

for i,v in pairs(guis:GetChildren()) do --The for loop that inserts all the guis in the guis folder into the guyi table

table.insert(guiTable, #guiTable+1, v)

end

 

local guiSelection = math.random(1,#guiTable) --Randomly selects a item from the table's index in it

local guiSelected = guiTable[guiSelection] --Gets the randomly selected item via the index that was randomly selected above

print(guiSelected.Name)

 

And then you can just put more guis in the folder (not with the same names of course) and it will automatically select one

🤡 You spoonfed him your not supposed to do that!!!

  • Downvote 1

Share this post


Link to post
Share on other sites
23 hours ago, yes112365595man said:

🤡 You spoonfed him your not supposed to do that!!!

Says who? He asked for help and i did not know how much scripting knowledge he had so i told him what things did so that he could easily adapt the system to his needs

  • Downvote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.