I'm trying to delete the player hats when the player spawns. Everything seems fine in the code, but it's not deleting my hats.
1 | game.Players.PlayerAdded:connect( function (player) |
2 | player.CharacterAdded:connect( function (character) |
3 | for _, child in ipairs (character:GetChildren()) do |
4 | if child.ClassName = = "Accessory" then |
5 | child:Destroy() |
6 | end |
7 | end |
8 | end ) |
9 | end ) |
*Updated to child:Destoy() but it still does not work
You have it right... But, because the hair is added after the fact you must wait for it to be added. Do this...
01 | game.Players.PlayerAdded:connect( function (player) |
02 | player.CharacterAdded:connect( function (character) |
03 | wait( 0.5 ) |
04 | for _,v in ipairs (character:GetChildren()) do |
05 | print (v.Name) |
06 | if v.ClassName = = "Accessory" then |
07 | v:Destroy() |
08 | end |
09 | end |
10 | end ) |
11 | end ) |
just do
1 | game.Players.PlayerAdded:connect( function (player) |
2 | player.CharacterAdded:connect( function (character) |
3 | character.Humanoid:RemoveAccessories() |
4 | end ) |
5 | end ) |
honestly idk if this is gonna work. I saw the removeaccessories function a while ago and i just never got around to actually trying it.