I have a game, and I want it to choose a random model that is in Lighting. How would I go about doing this?
✓ ANSWER ACCEPTED
How do I choose a random child of an object?
3 answers
✓ Accepted answer
local Lighting = game:GetService("Lighting")
local Map = Lighting:GetChildren()[math.random(1, #Lighting:GetChildren())]
I would use a loop (:GetChildren) and then use math.random for every loop cycle.
math.randomseed(tick())
local maps = game.Lighting:GetChildren()
print(maps[math.random(1,#maps)])
This discussion is preserved as it was. New answers, comments, and votes are closed.
