So I want to find a child of a folder randomly and then use the position of that part. How would you do this?
So far I have:
local parts = game.Workspace.PartsModel:GetChildren()
Now I need to try find ONE child of that at random. How would I do this?
Im writing this on my phone soo it might not be 100% right.
local randomchild = math.random(1,#parts) --choose random index number parts[randomchild] --use that index number to get the instance with that number
If you have any problem with the code above Please tell me
We can use math.random()
for this.
local Children = game.Workspace.PartsModel:GetChildren() local RandomIndex = math.random(1, #Children) local RandomChild = Children[RandomIndex] print(RandomChild.Name)