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

Selecting random obstacles from Server Storage?

Asked by 4 years ago
Edited 4 years ago

Let me explain what this is. So, basically what happens is:

ServerStorage > Clones > Stage1C > Set1 Set2 Set3 Set4

basically it selects 1 of the Set1,2,3, and 4. Each set inside has several obstacles across the entire map that are displayed for players to run. I don't want it to work that way anymore, how can I make it so that it goes to each Set but instead of selecting the entire set and all children inside, it only selects 1 child inside each set and places them all in the course for the player to play?

my apologies if I didn't give enough info. If you need more help understanding here is a picture of where I place all 4 sets:

https://imgur.com/55YFdzE

and inside each set, there will be 4 obstacles that every round 1 of them shows visible for the player to run throughout the course.

Core.Stage:ClearAllChildren();
    Stage = Stage:Clone();
    local randStageMap = game:GetService("ServerStorage"):FindFirstChild("Clones"):WaitForChild("Stage"..stageNumber.."C"):GetChildren()
    local actualMap = randStageMap[math.random(1,#randStageMap)]:Clone()
    actualMap.Parent = Core.Stage
    for _,obj in pairs(Stage:GetChildren()) do obj.Parent = Core.Stage; end;

0
What error did it give? CrypxticDoge 135 — 4y
0
There isn't any error. It just selects 1 of the 4 sets for the player to play. Instead, I want it to select 1 obstacle from inside of each "set1,2,3, and 4". There will be 4+ models inside each Set12,3,4. ItsJZaid 45 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

The for loop you are making is getting all the children and putting it in the stage. You might want to do this.

local children = Stage:GetChildren()
local random = math.random(1,x) --x is amount of children in the set
children[random].Parent = Core.Stage
Ad

Answer this question