Issue with command not working

I want to make it clone the map and move it to workspace and remove the other map from workspace. Though, this doesn’t seem to happen.
Here’s some parts of the commands script:

--// MAPS
local map1 = game.ServerStorage.Map1
local map1w = game.Workspace.Map1
local map2 = game.ServerStorage.Map2
local map2w = game.Workspace.Map2

--// CODE
function onChatted(msg, speaker)
    if checkAdmin(speaker) then
        local source = string.lower(speaker.Name)
        msg = string.lower(msg)
		    if msg == "!changemap map1" then
			map1:Clone().Parent = game.Workspace
			map2w:Remove()
		elseif msg == "!changemap map2" then
			map2:Clone().Parent = game.Workspace
			map1w:Remove()
            end
        end
    end

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:connect(function(msg)onChatted(msg, player) end)
end)

When I run the command “!changemap map1”, it doesn’t do anythin and doesn’t say an error in output.

Anything is appreciated, thanks!

1 Like

Probably doesn’t relate to why it’s not working, but Remove() is depreciated. Use Destroy() instead, or if you want to use it for later, just set its parent property to nil

1 Like

Destroy() doesn’t seem to work either.

You should add some print statements in various places. Such as after it checks if the speaker is an admin, and after it checks to see if the message is !changemap map1/changemap map2

1 Like