Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Anything wrong with this?

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.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.