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

How to u randomly take a map like a Minigame out of serverstorage and put it in Workspace?

4 answers

✓ Accepted answer

I think I'm on my phone so I cant test but map1 would be your map obviously

game.serverstorage.map1:Clone(Workspace)

3 comments

0

i think,*

0

k thanks

0

To randomly get one from a selection: local randomMap = game.ServerStorage:GetChildren()[math.random(1,#game.ServerStorage:GetChildren())] randomMap:clone().Parent = workspace

I'm unsure what you mean by randomly selecting a map, but to move a map into the workspace you would use something like this

local map = game.ServerStorage.map
map:Clone(Workspace)

this would make a clone of the map and move it into the workspace(so that you could destroy the map and clone it again, effectively resetting the map), but if you just wanted to move the whole thing and not make a duplicate of it, you would just remove the :Clone() so it looked like this

local map = game.ServerStorage.map
map.Parent = game.Workspace

If you have any questions just let me know and I'll do my best to answer them.

:getChildren() of your storage folder and then use math.random to select an index number to clone?

then just do

local map = game:GetSeervice("ReplicatedStorage"). *the output from the table*
local choice = map:clone()
choice.Parent game.Workspace

? idk

All these answers are right but lack the random variation asked in the question.

Suppose there exists a folder called Maps within ServerStorage and inside is each map grouped together in individual models.

local ServerStorage=game:GetService('ServerStorage')
local maps=ServerStorage:WaitForChild('Maps')

function cloneMap()
	local rng=Random.new():NextInteger(1,#maps) --#maps is the number of maps within the Maps folder, hence a random number is picked to determine the random map
	local mapClone=maps[rng]:Clone()
	mapClone.Parent=game.Workspace
end

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