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

Hats Not Being Removed?

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

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)

5 comments

0

:Remove() is deprecated. Use :Destroy()

0

That didn't work either.

0

Neither :Remove() or :Destroy() worked.

0

.... Jesus. I am gonna write this script from scratch, you're obvioudly too inexperienced to do it yourself.

0

make it capital 'D'

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