Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a more efficient way of getting a random part?

So basically, I want to know if there's a more efficient was of getting a random thing. Let's say i have 100 parts, and I want to get a random one out of all of them. I could do the math.random() method, but it would be tedious. Is there any other efficient way?

3 comments

0

If you mean that you want a completely random part, since math.random() isn't completely random, try looking at this: https://devforum.roblox.com/t/a-random-feature/64517

0

Ughhh why does this keep happening to me? My reputation is going down by the minute

0

@bossay6. Question has been answered

1 answer

✓ Accepted answer
-- Declaration Section 

local model = game:GetService("Workspace").Parts
local parts = model:GetChildren()

-- Output Section 

local randomInteger = math.random(#parts)
local randomPart = parts[randomInteger]
print (randomPart)

1 comment

0

thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.