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

Hats Not Being Removed?

Asked by 8 years ago

Title is basically self explanatory.

In this script here, the hats will not be removed. The problem is on line 5. I've tried using :Destroy(), :Remove() and :ClearCharacterAppearance() but none have worked. All other lines of the script work, except for line 5.

wait(0.1)

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
player:ClearCharacterAppearance()
player.CameraMode = Enum.CameraMode.LockFirstPerson
player.Character.Humanoid.WalkSpeed = 10
player.Character.Humanoid.Name = "Hoomanoid"
mouse.Icon = "rbxassetid://251444305"

Any help is much appreciated, thanks!

1 answer

Log in to vote
0
Answered by 8 years ago

You could do this:

repeat wait() until p.Character
local char = p.Character
for _,v in pairs (char:GetChildren())
    if v:IsA("Hat") then
        v:destroy()
    end
end

EDIT:

Hierarchy:

  • Workspace
    • Script

Script:

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function(char)
        repeat wait() until char.Head
        for _,v in pairs (char:GetChildren())
            if v:IsA("Hat") then
                v:Destroy()
            end
        end
    end)
end)
0
:Remove() is deprecated. Use :Destroy() Im_Kritz 334 — 8y
0
That didn't work either. sidekick83 80 — 8y
0
Neither :Remove() or :Destroy() worked. sidekick83 80 — 8y
0
.... Jesus. I am gonna write this script from scratch, you're obvioudly too inexperienced to do it yourself. TheDeadlyPanther 2460 — 8y
0
make it capital 'D' JasonTheOwner 391 — 8y
Ad

Answer this question