how do i make a script where when i execute it it will clone all of the workspace into replicated storage, delete the stuff in the original, and then take the clone back, ive tried doing it ill show what i tried.

function onChatted(msg, recipient, speaker) 

local source = string.lower(speaker.Name) -- Converts name of speaker to lowercase
msg = string.lower(msg)

	if (msg == "/map") then --Chat Command
		wait(1)	
		game.Workspace:ClearAllChildren()
		wait(0.2)
		wait(1)
	--Action here.
	end 

end 


-- Do not edit without experience.
function onPlayerEntered(newPlayer) 
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered)

then the 2nd script which executed after

function onChatted(msg, recipient, speaker) 

local source = string.lower(speaker.Name) -- Converts name of speaker to lowercase
msg = string.lower(msg)

	if (msg == "/map") then --Chat Command
		wait(1)
		local original = game.Workspace
		local copy = game.ReplicatedStorage.Map:Clone()

		wait(0.2)
		copy.Parent = game.Workspace
		wait(1)
	--Action here.
	end 

end 


-- Do not edit without experience.
function onPlayerEntered(newPlayer) 
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered)

2 comments

0

copy everything in workspace and group it, name it Map duplicate it so there is 2 and put one in ReplicatedStorage, did u do that?

0

yes