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

Why doesn't my hat remover script do anything?

So I have a script:

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		if char:FindFirstChild('Accessory') then
			local gethats = char:GetChildren()
			for i,v in pairs(gethats) do
				if v.ClassName == "Accessory" then
					v:Destroy()
				end
			end
		end
	end)
end)

It doesn't do anything and I don't get any errors either.

1 answer

✓ Accepted answer

###The accessories in the character are not called Accessory. For example, the Beautiful Hair is called "Ultra-FabulousHair".

###You wouldn't need a loop to do this, though.

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:WaitForChild("Humanoid"):RemoveAccessories()
    end)
end)

###The RemoveAccessories method does this for us. On a side note, switch to :Connect(), as :connect() is deprecated and should not be used in new work.

2 comments

0

Connect doesn't work for me in studio

0

.

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