Number is not a valid member when picking random child

I keep getting
image
and all im doing is


Is my code wrong??? I dont see why…
And this is where i create the folder…

help.

Try

local folder = tablefolder:GetChildren()
local tble = folder[math.random(1,#tablefolder:GetChildren())]

The reason why it doesn’t work is because [] are used to get the child of an object, but the random number is not a child of the folder. Basically, []'s are used instead of .'s in some cases. I assume you’re trying to get a random child in a folder. To do this, you’d need to create a table (first line of the code) by using :GetChildren(). After, you may use [number] to get a child since it’s now a table.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.