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

What's wrong with this script? [SOLVED]

Asked by 10 years ago

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.

3 answers

Log in to vote
6
Answered by
AxeOfMen 434 Moderation Voter
10 years ago

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!

Ad
Log in to vote
1
Answered by
DrJonJ 110
10 years ago
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().

Log in to vote
0
Answered by 10 years ago

DonĀ“t forget to put MakeJoints()

Answer this question