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

script.Parent.MouseClick:Connect(function()
    print("button pressed")
    local Room = math.random(1,2)
    if Room == 1 then
        local map = game.ReplicatedStorage.TestMaps.Map1:Clone()
        print("cloned")
        map.Parent = game.Workspace
        print("parent changed")
    map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
        wait(0.1)
        end
    if Room == 2 then
        local map = game.ReplicatedStorage.TestMaps.Map2:Clone()
        print("cloned")
        map.Parent = game.Workspace
        print("parent changed")
        map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
        wait(0.1)
    end
    script.Parent.Parent:Destroy()
end)

any help would be nice :)

1 answer

Log in to vote
0
Answered by 3 years ago

nvm i got it.

script.Parent.MouseClick:Connect(function()
    local Kids = game.ReplicatedStorage.TestMaps:GetChildren()

    local Ran = math.random(1,#Kids)

    local Fartz = Kids[Ran]

    local map = Fartz:Clone()
    print("cloned")
    map.Parent = game.Workspace
    print("parent changed")
    map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
end)
Ad

Answer this question