random=game.Workspace.minigames.selection:getChildren() for i=1,#random do print(math.random(i)) end
This prints EVERYTHING inside the table. I can't figure out how to only print ONE thing out of the table randomly.. It's extremely obvious but I can't find it anywhere and help would be appreciated... t-t
First, pick a better name:
local children = workspace.minigames.selection:GetChildren() -- children. Not "random"
Where you are printing:
print( math.random(#children) )
This will print a number (not a thing in the table).
But you're doing that in a for
loop:
for i = 1, #children do
So if you only want to do it once, just don't include the loop.
If you want one random element from a list, you can do this:
local randomIndex = math.random(#list) -- a random INDEX of `list` print( list[ randomIndex ] ) -- a random thing (random becaue it's at a random *index*) from list