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

How Can I Print The Map That has been Chosen? [closed]

Asked by 5 years ago
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

Closed as Not Constructive by User#24403, Gey4Jesus69, zblox164, and green271

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Vain_p 78
5 years ago

Try doing

if randomMap == [1] then
    print("Yellow")
elseif randomMap == [2] then
    print("ZigZag")
elseif randomMap == [3] then
    print("Sphere")
end
0
If thats does not work try replacing the [1] [2] [3] with 1 2 3 Vain_p 78 — 5y
0
Thank You, Second method works! BloxEnergy -76 — 5y
0
np Vain_p 78 — 5y
0
Don't ever use a string key in a comparison. Why would you even want to do that? Fifkee 2017 — 5y
Ad
Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago

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.