How to delete Accessory, Shirt, Pants, Body Colors, T-Shirt on player when it spawn to workspace?
local ClassName = { "Accessory", "Shirt", "Pants", "Body Colors", "T-Shirt" } workspace.ChildAdded:connect(function(object) local NewPlayer = game.Players:playerFromCharacter(object) if NewPlayer ~= nil then for index, value in pairs(object:GetChildren()) do if value:IsA(ClassName) then value:Destroy() end end end end)
Use the PlayerAdded event to get the player that has just joined and then use the CharacterAdded event to get the character of that player
Here is what your script should look like:
local ClassName = { "Accessory", "Shirt", "Pants", "BodyColors", "Shirt" } game.Players.PlayerAdded:connect(function(player) -- Use the PlayerAdded to get the player that has just been added player.CharacterAdded:connect(function(character) -- Use the CharacterAdded event to get the character of 'player' wait(2) -- Add a wait just in case that player objects have not loaded yet for _,obj in pairs(character:GetChildren()) do -- Loops through each object of the character and returns the value for i, CN in pairs(ClassName) do -- loops through the class names and returns the value of each if obj:IsA(CN) then -- checks to see if the objects class name is the value of the Class Name in the array defined before obj:Destroy() end end end end) end)