Here's my script:
Forest = game.Lighting.Forest Maps = {Forest} randommap = math.random(1, #Maps) Maps[randommap]:Clone()
Okay, I know there should probably be more than one map in Maps, but I only have one built for right now, and also shouldn't it work without any other ones?
Well, anyway, it's not cloning the map like it should. Nothing's showing up in the output. Please help.
You need to set the parent of the clone. There are a couple of ways to do this.
If you do not need to modify the clone or get a reference to the clone for later usage:
Maps[randommap]:Clone().Parent = game.workspace
If you need a reference to the clone to modify its properties or for later usage:
local selectedMap = Maps[randommap]:Clone() selectedMap.Parent = game.workspace
Good luck!
Forest = game.Lighting.Forest Maps = {Forest} randommap = math.random(1, #Maps) Maps[randommap]:Clone()
You could also do this:
Maps = { game.Lighting.Forest; } randomMap = math.random(#Maps) randomMap:clone().Parent = workspace
You could also just do Maps[math.random(#Maps)]:clone().Parent = workspace.CurrentMap
so you have it all in one line.
Just put a model in the workspace called "CurrentMap" and when clearing the map do workspace.CurrentMap:GetChildren()[1]:Destroy()
.