Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help :Destroy() on Character items?

Asked by 8 years ago
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

0
Mind adding wait(1) on top of the script? This may be a timing problem. XAXA 1569 — 8y
0
Did nothing NinjoOnline 1146 — 8y
0
no errors? XAXA 1569 — 8y
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 NinjoOnline 1146 — 8y
View all comments (5 more)
0
Add a wait(1) directly under charactersetup, before the for-loop? XAXA 1569 — 8y
0
Did you try setting breakpoints? Wutras 294 — 8y
0
Why not disable the LoadCharacterAppearance property of players. It will give you the most default character model. M39a9am3R 3210 — 8y
0
Where's that? It isn't in the Player, only CharacterAutoLoads, which disables them from respawning NinjoOnline 1146 — 8y
0
Set it in a script. player.CanLoadCharacterAppearance = false. Pyrondon 2089 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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)


Ad

Answer this question