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

How could i get a map choser?

Asked by 10 years ago

I got most of this done, but when the next round starts it does not work correctly. Any way to stabilize this?

function RandomizeMaps() List1 = Game.Lighting.List1:GetChildren() List2 = Game.Lighting.List2:GetChildren() List3 = Game.Lighting.List3:GetChildren() Randomize1 = List1[math.random(1,#List1)] Randomize2 = List2[math.random(1,#List2)] Randomize3 = List3[math.random(1,#List3)] Import1 = script.Maps.Map1 Import2 = script.Maps.Map2 Import3 = script.Maps.Map3 Import1.Value = Randomize1.Name Import2.Value = Randomize2.Name Import3.Value = Randomize3.Name end

function AddMaps() Voted1 = Game.Workspace.Lobby.Voting.Voted1 Voted2 = Game.Workspace.Lobby.Voting.Voted2 Voted3 = Game.Workspace.Lobby.Voting.Voted3 Map1 = script.Maps.Map1 Map2 = script.Maps.Map2 Map3 = script.Maps.Map3 if Voted1.Value > Voted2.Value and Voted3.Value then MapsAdd = Game.Lighting.List1:FindFirstChild(Map1.Value) Values = Game.Workspace.Chosen Values.Value = MapsAdd.Name MapsAdd:Clone().Parent = Game.Workspace MapsAdd:MakeJoints() elseif Voted2.Value > Voted1.Value and Voted3.Value then MapsAdd = Game.Lighting.List2:FindFirstChild(Map2.Value) Values = Game.Workspace.Chosen Values.Value = MapsAdd.Name MapsAdd:Clone().Parent = Game.Workspace MapsAdd:MakeJoints() elseif Voted3.Value > Voted1.Value and Voted2.Value then MapsAdd = Game.Lighting.List3:FindFirstChild(Map3.Value) Values = Game.Workspace.Chosen Values.Value = MapsAdd.Name MapsAdd:Clone().Parent = Game.Workspace MapsAdd:MakeJoints() else MapChoice = Game.Lighting.Maps:GetChildren() Picking = MapChoice[math.random(1,#MapChoice)] Values = Game.Workspace.Chosen Values.Value = Picking.Name MapsAdd = Game.Lighting.List1:FindFirstChild(Values.Value) MapsAdd:Clone().Parent = Game.Workspace MapsAdd:MakeJoints() end end

1 answer

Log in to vote
0
Answered by
Nickoakz 231 Moderation Voter
10 years ago

Next time, please put the lua quotes on your code.

Here is a map picker.

maps={game.Lighting["Map1"],game.Lighting["Map2"]} --This is a table, so you can add unlimited maps.
function PickMap()
    local num=math.random(1,#maps)
    local map=maps[num]:Clone()
    map:MakeJoints()
    map.Parent=Workspace
end 

Edit: If your model has numbers in it, don't forget the special [" "]..

Ad

Answer this question