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

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

Asked by 4 years ago

Closed as Non-Descriptive by JesseSong, moo1210, killerbrenden, namespace25, Xapelize, and Ziffixture

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

4 answers

Log in to vote
0
Answered by 4 years ago

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

game.serverstorage.map1:Clone(Workspace)
0
i think,* GAMER_64T 32 — 4y
0
k thanks Verbalase_notreal 23 — 4y
0
To randomly get one from a selection: local randomMap = game.ServerStorage:GetChildren()[math.random(1,#game.ServerStorage:GetChildren())] randomMap:clone().Parent = workspace darkelementallord 686 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

Log in to vote
0
Answered by 4 years ago

: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

Log in to vote
0
Answered by
Ortron 27
4 years ago

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