Clearing issue [ NEED HELP WITH COMMAND FUNCTION]

Generally I just want a script that can delete everything in one sweep and I’m pretty sure there’s a simple command for it you can run into the command bar, I think it’s something like delete instance but I’m not sure how to word it properly.

Well, you could detect who could be a Admin/Mod to gain access to this command, then with the correct command chatted using the Player.Chatted event, you can loop through everything inside the workspace, then check if the Parts are equal to a Baseplate or Player to ignore them:

--ServerScript inside ServerScriptService
local AdminList = { --I used usernames for simpler use, you can use User ID's if you want
    "vercils";
    "Jackscarlett";
    "OtherRandomAdmin";
} 

local ClearCommand = "/clear"
game.Players.PlayerAdded:Connect(function(Player)
    if table.find(AdminList, Player.Name) then --Checking if the player who joined is a valid Admin
        Player.Chatted:Connect(function(Message) --Connect our chatted event here
            if Message == ClearCommand then

                for _, Part in pairs(workspace:GetChildren()) do --You can use GetDescendants to get everything destroyed if parts are inside parents if you want
                    if Part.Name ~= "Baseplate" and not game.Players:GetPlayerFromCharacter(Part) then
                        Part:Destroy()
                    end
                end

            end
        end)
    end
end)
1 Like