How to pick random Children

I want to pick some random children.

My Explorer is
unknown_2022.10.08-10.24
and script is,

do
	
	local model = game.Workspace.Model
	
	local part = model[Random(#model:GetChildren())]
	
	print(part.Name) --It doesnt work
	
end

thank you

2 Likes

This might help you out

local t1 = {}
local random

for i, v in pairs(game.Workspace.Model:GetChildren()) do
table.Insert(t1, v.Name)
end

random = t1[math.Random(1, #t1)]

Or just do

local children = workspace.Model:GetChildren()
local randomChild = children[math.random(1, #children)]
8 Likes