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?
✓ ANSWER ACCEPTED
Is there a more efficient way of getting a random part?
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.

3 comments
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
Ughhh why does this keep happening to me? My reputation is going down by the minute
@bossay6. Question has been answered