Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Can I Print The Map That has been Chosen?

local Maps = {'Yellow','ZigZag','Sphere'}
local randomMap = math.random(1, #Maps)
for i,v in pairs(Maps) do
	if randomMap == i then
		local storage = game:GetService("ReplicatedStorage")
		local map = storage.Maps:WaitForChild(v):clone()
		map.Parent = workspace.MapPlaying

2 answers

✓ Accepted answer

Try doing

if randomMap == [1] then
	print("Yellow")
elseif randomMap == [2] then
	print("ZigZag")
elseif randomMap == [3] then
	print("Sphere")
end

4 comments

0

If thats does not work try replacing the [1] [2] [3] with 1 2 3

0

Thank You, Second method works!

0

np

0

Don't ever use a string key in a comparison. Why would you even want to do that?

First, create a folder and then after that put all of the maps in their. Make sure to place the folder in ServerStorage. Then, name the folder "Maps"

local MapList = game:GetService("ServerStorage").Maps:GetChildren() --Creates a table of the maps
local Index = math.random(1,#MapList) --Chooses a random map and then turns it into a number
local ChosenMap = MapList[Index]:Clone() --Find it in the table and clones it
ChosenMap.Parent = workspace.MapPlaying --Makes the parent into workspace.MapPlaying
print("Map Chosen: ", ChosenMap.Name) --Prints it.

This discussion is preserved as it was. New answers, comments, and votes are closed.