maps = game.ServerStorage.Maps:GetChildren() function loadMap(map) table.foreach(Workspace.currentMap:GetChildren(), function(i,v) v:Remove() end)--remove children nmap = map:Clone() nmap.Parent = game.Workspace.currentMap nmap:MoveTo(Workspace.mapLocation) end function randMap() loadMap(maps[math.random(1,#maps)]) end
It's a map changing script.
First of all, table.foreach is deprecated. Use this instead:
for i,v in pairs(game.Workspace.currentMap:GetChildren()) do v:Remove() end
Otherwise that looks like it would work just fine.