Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can you remove all players hats in a script?

local lplayer = game.Players.LocalPlayer

for k,s in pairs(lplayer) do
	if s:isA("Hat") and lplayer:isA("Humanoid") then
		s:Destroy()
	end
end

I've done this so far, but it's not working, an help?

1 answer

✓ Accepted answer

Basically all you want to do is loop through the player''s character to find a hat. This is how you will do this:

player = game.Players.LocalPlayer

for i,v in pairs(player.Character:GetChildren())do
	if v:IsA("Hat") then
		v:Destroy()
		wait()
	end
end

This will destroy all items that are a hat in the player's character

2 comments

0

Doesn't work at all. For some strange reason....

0

Nevermind! Done it! I just need to put a wait(2) So it doesn't auto-regen it instantly!

This discussion is preserved as it was. New answers, comments, and votes are closed.