Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can you remove all players hats in a script?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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

0
Doesn't work at all. For some strange reason.... iDarkGames 483 — 8y
0
Nevermind! Done it! I just need to put a wait(2) So it doesn't auto-regen it instantly! iDarkGames 483 — 8y
Ad

Answer this question