I tried findfirstchild waitforchild its so annoying please help I want the players hat to be destroyed when they join.
COMMUNITY QUESTION
How do I remove hats onjoin?
1 answer
If you want all the hats a player has to be destroyed everytime they respawn, then instead of using waitforchild or findfirstchild, you should use the PlayerAdded event and CharacterAdded event to search through the entire character for hats using the :IsA() method and then destroy the hat.
local players = game:GetService'Players' -- Get the players service
players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c) --This event will fire whenever the character is spawned
wait(.8) -- Hats take a few second to load
for i,v in next,c:GetChildren() do --Search through the entire character
if v:IsA("Hat") then -- Check if v is a hat
v:Destroy() --Destroy the hat
end
end
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Your normal version of this script didn't work I tried making it a script and a localscript.
Try it again with the wait, I forgot that hats take a little time to be loaded in by the game server.
k thanks
I added a wait for 10 I even made them localscripts and scripts into workspace and starterpack any idea why it doesnt work?