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

Why doesn't the hat remover work in R6?

I had a hat remover working in my game but when I changed it to R6, the hat remover stopped working so I tried to make a new one but nothing seemed to work. Can someone help me by pointing out what I've done wrong? There are no errors in the output bar.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local c = char:GetChildren()
		if c.ClassName == "Accessory" then
			c:Destroy()
			c:Remove()
		end
	end)
end)

1 answer

You didn't enumerate through the assets of the Character, meaning you couldn't locate every Accessory to properly remove them. You also tried to call methods of Instance on an array, as :GetChildren() return a table.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Accessories = Character:GetChildren()
		for _,Accessory in pairs(Accessories) do
			if (Accessory:IsA("Accessory")) then
				Accessory:Destroy()
			end
		end
	end)
end)

1 comment

0

The script still doesn't work. Nothing in the output bar either.

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