Well, I have a script that removes all Accessories from the character, but for some reason they player sometimes has it and sometimes doesn't, is there a better way to remove hats?
Stuff = script.Parent:GetChildren() for _, thing in pairs (Stuff) do if thing.ClassName == "Accessory" then thing:remove() end end
You have to first wait until the character loads its appearance before you remove anything. These may help: Player:HasAppearanceLoaded() , Player:ClearCharacterAppearance() , Player.CharacterAppearanceLoaded .
If you want to remove all accessories, that's easy. If you want to remove only literal "hats" then you should destroy Hat objects, as well as accessories which have a "HatAttachment". Here is what I would do:
player.CharacterAppearanceLoaded:connect(function(char) for _,v in pairs(char:GetChildren()) do if v:IsA('Hat') or (v:IsA('Accessory') and v:WaitForChild('Handle'):FindFirstChild('HatAttachment')) then v:Destroy() end end end)
However I notice that this event can be inaccurate, so here is a possibly safer option. They both use the same check though.
character.ChildAdded:connect(function(v) if v:IsA('Hat') or (v:IsA('Accessory') and v:WaitForChild('Handle'):FindFirstChild('HatAttachment')) then wait() v:Destroy() end end)