Use a toggle depending on what you want to toggle.
Lua Code:
local SomeBooleanVariable -- could be a SavedVaraible to save between sessions.
SlashCmdList.MYSLASHFUNCTION = function(msg)
SomeFrame:SetShown(not SomeFrame:IsShown()) -- show/hide a frame
SomeBooleanVariable = not SomeBooleanVariable -- toggle boolean variable
if SomeBooleanVariable then -- and action it
-- do thing if true
else
-- do thing if false
end
end