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

Pick A Random Map

Asked by 10 years ago

how can i make a script that will pick a random map i make in my game

2
You need to provide more information than this. How are your maps implemented? Are they models stored in ServerStorage? Are they generated via a script? The answer will depend on what you mean by `map` AxeOfMen 434 — 10y

3 answers

Log in to vote
1
Answered by 10 years ago

Here ya go

Map1 = game.ServerStorage["Map"]
Map2 = game.ServerStorage["Map"]
Map3 = game.ServerStorage["Map"]
Maps = {Map1, Map2, Map3} --Make sure the maps are Objects

local randmap = math.random(1, #Maps)

print(Maps[randmap].Name .. " Has been picked!")
0
This could be more efficient modFrost 130 — 10y
Ad
Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
10 years ago

Answer:

-- If you want no hints remove the lines ending in nohint
-- STUFF --
local h = Instance.new("Hint", Workspace) -- nohint
local findMaps = game.ServerStorage["Maps"]:GetChildren()
-- PICKING MAP --
local map = findMaps[math.random(#findMaps)]
print(map.Name.." has been chosen!")
h.Text = "map.Name.." has been chosen!"" -- nohint
-- LOADING MAP --
m = map.Clone()
m.Parent = Workspace
Log in to vote
-1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

ServerStorage > Maps > Put all your maps in here.

local mapFolder = game.ServerStorage["Maps"]:GetChildren()
local map = mapFolder[math.random(#mapFolder)]
print(map.Name.. " chosen")

Answer this question