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

How to find a random map, and select it as a variable?

Alright so I've seen alot of people who can get a random map in their games, and print the name of this random map, and clone this random map into workspace. First how do you get the random map? Second, how do you select it? Third how would you be able to name it a variable so you could;

print("Map is "..MapName.."!")

Any help with this please, I'm a beginner at scripting.

1 comment

0

You can put all of the map names into a table and then use 'MapName = math.random(1, #TABLENAME)'

1 answer

✓ Accepted answer

local MapsLocation = game.Lighting:WaitForChild('Maps') -- or anything lol local maps = {} for _,v in pairs(MapsLocation:GetChildren()) do table.insert(maps, v.Name) end --Run ur script local selectMap = maps[math.random(1, #maps)] print('Map selected: ' .. selectMap)

3 comments

0

This works perfectly :D I need reputation, how will I get?

0

When someone upvotes your answer, or when the asker accepted it.

0

Can u upvote me pls :D

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