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

Remove Players hats?

Asked by 9 years ago

I tried using this script to remove a players hat but its kinda broken. Please help

PhantomHead = Phantom.Character.Head
PhantomHats = PhantomHead.GetInstance("Hat")
PhantomHats:Remove()

1 answer

Log in to vote
2
Answered by 9 years ago

You could remove all player hats by iterating over a table of all of the character's children. It seems as if you didn't define what Phantom is and I would also suggest using Destroy(). This script goes through all of the children, checks whether or not it is a hat object and destroys it if it is but leaves it alone if it is not. Please remember to define what phantom is.

--phantom = -- define who phantom is--

for i, v in pairs(phantom.Character:GetChildren()) do
    if v:IsA("Hat") then
        v:Destroy()
    end
    wait()
end
1
You do not need the wait, it won't lag the game. EzraNehemiah_TF2 3552 — 9y
Ad

Answer this question