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

anyone got any easier way to do pick what map to spawn?

Asked by 3 years ago

hello scripting helpers! i just wanna know if theres an easier way to pick what map to spawn. thats about it

01script.Parent.MouseClick:Connect(function()
02    print("button pressed")
03    local Room = math.random(1,2)
04    if Room == 1 then
05        local map = game.ReplicatedStorage.TestMaps.Map1:Clone()
06        print("cloned")
07        map.Parent = game.Workspace
08        print("parent changed")
09    map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
10        wait(0.1)
11        end
12    if Room == 2 then
13        local map = game.ReplicatedStorage.TestMaps.Map2:Clone()
14        print("cloned")
15        map.Parent = game.Workspace
View all 21 lines...

any help would be nice :)

1 answer

Log in to vote
0
Answered by 3 years ago

nvm i got it.

01script.Parent.MouseClick:Connect(function()
02    local Kids = game.ReplicatedStorage.TestMaps:GetChildren()
03 
04    local Ran = math.random(1,#Kids)
05 
06    local Fartz = Kids[Ran]
07 
08    local map = Fartz:Clone()
09    print("cloned")
10    map.Parent = game.Workspace
11    print("parent changed")
12    map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
13end)
Ad

Answer this question