Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I pick a random child of game.Workspace? [closed]

Asked by 6 years ago

How do I pick a random child?

Like I want this NPC to go to a random tree located in Workspace but how do I do this?

Locked by Shawnyg

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
-1
Answered by 6 years ago

math.random!

while wait(1) do
    local object = workspace:GetChildren()[math.random(1,#workspace:GetChildren())]
end

I don't think I have to explain, if you have any questions though, please ask

0
omg I forgot about it! thank you!!! CrazyTwinkle -1 — 6y
0
np User#20388 0 — 6y
0
Can you set this as best answer? :P User#20388 0 — 6y
0
Thanks, I was looking for the same thing. GroovyFhish 8 — 6y
0
np User#20388 0 — 6y
Ad