Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help :Destroy() on Character items?

function charactersetup(player, character)
	for _, v in pairs(character:GetChildren()) do
		if v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("CharacterMesh") then
			v:Destroy()
		end
	end
end

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		charactersetup(player, character)
	end)
	
	if player.Character and player.Character.Parent then
		charactersetup(player, player.Character)
	end
end)

This is an odd bug. Sometimes it gets rid of none of the characters stuff, sometimes it gets rid of a few things. How can I get it to destroy EVERYTHING

9 comments

0

Mind adding wait(1) on top of the script? This may be a timing problem.

0

Did nothing

0

no errors?

0

Nope, like I said, is may destory some of the stuff, like maybe 1-2 hats, the shirt, and maybe an arm and torso mesh, but it still leaves a few things left on the character, instead of destroying it all

0

Add a wait(1) directly under charactersetup, before the for-loop?

0

Did you try setting breakpoints?

0

Why not disable the LoadCharacterAppearance property of players. It will give you the most default character model.

0

Where's that? It isn't in the Player, only CharacterAutoLoads, which disables them from respawning

0

Set it in a script. player.CanLoadCharacterAppearance = false.

1 answer

✓ Accepted answer

if you wish to destroy EVERYTHING, shirts, pants, and hats then use this

function charactersetup(player, character)
	game:GetService("Players"):GetPlayerFromCharacter(character):ClearCharacterAppearance()
	--Note: This will destroy EVERYTHING! Including the bodycolors and such.
	--However it doesn't remove t-shirts, head meshes, or faces.
end

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        charactersetup(player, character)
    end)

    if player.Character and player.Character.Parent then
        charactersetup(player, player.Character)
    end
end)


This discussion is preserved as it was. New answers, comments, and votes are closed.