Tiwernik
(Tiw)
January 1, 2021, 2:00pm
#1
Hello,
I have a problem with my accessory removing script.
It does not detect accessories (or at least the “DOGE” one)
I tried making it check for the handle and check if it is not a tool. Didn’t work.
The script is a script in SSS (ServerScriptService). Its for giving the player custom clothes, tools, accessories etc. if they are on a team.
for i, child in pairs(char:GetChildren()) do
if child:IsA("Accessory") then
child:Destroy()
end
end
Thanks if you can help.
When does this script run? Is it connected to CharacterAdded
event?
Tiwernik
(Tiw)
January 1, 2021, 2:08pm
#3
Indeed, the first 2 lines are:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
Then it’s probably not working because the code is running before game adds the accessories to player’s character. Try to change CharacterAdded
event with CharacterAppearanceLoaded
event.
Tiwernik
(Tiw)
January 1, 2021, 2:11pm
#5
It didn’t work.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(char)
Try:
for i, child in pairs(char:GetDescendants()) do
if child:IsA("Accessory") then
child:Destroy()
end
end```
TwyPlasma
(TwyPlasma)
January 1, 2021, 2:21pm
#7
You could try
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAppearanceLoaded:Connect(function(char)
local hum = char:FindFirstChild("Humanoid")
hum:RemoveAccessories()
end)
end)
Sorce: Modified from the developer hub example here
Tiwernik
(Tiw)
January 1, 2021, 2:24pm
#8
Both slothfulGuy’s and TwyPlasma’s solutions worked, thanks alot.
Some accessories may display as Hats you might want to also look out for the “Hat” class. It is deprecated and by default all catalog items are converted to accessories but if you use any models from the toolbox they may still appear as Hats.
Alternatively, sometimes accessories can take a while to load. It’s not like they exist when Character is added.
Consider adding a wait and see if that resolves your problem.
1 Like
Thank you soo much, you help me a lot