I've set a few random map variables, and I'm not sure if the clone one is correct, but I don't know enough about it to find out. Can someone help?
local maps = {Map1, Map2, Map3, Map4, Map5} local randomMap = math.random(1,#maps) clone = game.Lighting..randomMap:clone()
There's a few things wrong with this: First of all, in the 'maps' table you need to add speech marks around the string-values, like this:
local maps = {"Map1", "Map2", "Map3", "Map4", "Map5"}
Then instead of using normal brackets in line 2 use square brackets, and you need to call the table- like so:
local randomMap = maps[math.random(1, #maps)] -- This will call the 'maps' table, and select a random value from it, in this case the map names.
Finally, now you've called a value from the table you can use that- so you would do this:
clone = game.Lighting:FindFirstChild(randomMap):Clone() clone.Parent = Game.Workspace -- Make sure to set the clones parent.
Now if you put all of that together you should get:
local maps = {"Map1", "Map2", "Map3", "Map4", "Map5"} local randomMap = maps[math.random(1, #maps)] clone = game.Lighting:FindFirstChild(randomMap):Clone() clone.Parent = Game.Workspace -- Make sure to set the clones parent.
This should work, hope it helps! :)
clone works on objects
. This means a variable like game.Workspace.Model
.
You also have to specify the parent of the clone:
clone.Parent = game.Workspace