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

Accessory remover not working?

Asked by 4 years ago

So basicaly I made an accessory remover that removes your accessories once your character has been added to the game so it removes even after respawn. It should remove only if you are NOT on one specific team but it doesn't work and I don't know why.

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if plr.TeamColor ~= BrickColor.new("White") then
            for i,v in pairs(char:GetChildren()) do
                if v:IsA("Accessory") then
                    v:Destroy()
                end
            end
        end
    end)
end)

1 answer

Log in to vote
1
Answered by 4 years ago

It is possible that when the character is added, not all the accessories have been loaded. You can fix that by simply doing:

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAppearanceLoaded:Connect(function(char)
        if plr.TeamColor ~= BrickColor.new("White") then
            for i,v in pairs(char:GetChildren()) do
                if v:IsA("Accessory") then
                    v:Destroy()
                end
            end
        end
    end)
end)

Also, there is a method in a Humanoid that already does this function: Humanoid:RemoveAccessories()

0
omg thank you, lmao im dumb SpeedyTV_1 88 — 4y
Ad

Answer this question