So basically, My script, you have to type the command "run/..." DotDotDot meaning the map name. Which I done. But I want the script to also remove the old map and replace it with the new map.
local current_map;
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(chatmsg)
if chatmsg:sub(1,4) == "run/" then
local map = game.ServerStorage:FindFirstChild(chatmsg:sub(5))
local backup = map:clone()
if map then
if current_map then
current_map.Parent = game.ServerStorage
end
map = backup:clone()
map.Parent = workspace.Objects
current_map = map
end
end
end)
end)

2 comments
Thanks for your help Goulstem :-) but I have a question how do i make it remove the map that is already there when the game starts then when you run the command it will remove that map that is already there and then spawn the new map?
You can initially set the current_map variable to your map that is in the workspace :)