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

Remove all accessories 100% all the time?

Asked by 6 years ago

I'm struggling hard at this because I can't know for sure if it gets deleted or not. Sometimes it does, sometimes it don't. Can someone give me a tip about this?

My current script:

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        wait(0.5)
    for i, v in pairs (char:GetChildren()) do
        if v.ClassName == 'Accessory' then
            v:Destroy()
        end
        if v.ClassName == 'Hat' then
            v:Destroy()
        end
    end
    end)
end)

1 answer

Log in to vote
0
Answered by
clc02 553 Moderation Voter
6 years ago

Instead of hoping that all the accessories get loaded at a certain time, look up any items added to the player that is an accessory.

    plr.CharacterAdded:Connect(function(char)
    for i, v in pairs (char:GetChildren()) do
        if v.ClassName == 'Accessory' or v.ClassName == "Hat" then
            v:Destroy()
        end
    char.ChildAdded:Connect(function(child)
          if child.ClassName == "Accessory" or child.ClassName == "Hat" then
            child:Destroy()
          end
        end)
    end
    end)
0
Thanks! MineBlow111 39 — 6y
0
That wasn't the question though, or related to the problem. Problem is hats/accessories take a moment to load in. clc02 553 — 6y
Ad

Answer this question