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

Remove all accessories 100% all the time?

I'm struggling hard at this because I can't know for sure if it gets deleted or not. Sometimes it does, sometimes it don't. Can someone give me a tip about this?

My current script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		wait(0.5)
	for i, v in pairs (char:GetChildren()) do
		if v.ClassName == 'Accessory' then
			v:Destroy()
		end
		if v.ClassName == 'Hat' then
			v:Destroy()
		end
	end
	end)
end)

1 answer

✓ Accepted answer

Instead of hoping that all the accessories get loaded at a certain time, look up any items added to the player that is an accessory.

    plr.CharacterAdded:Connect(function(char)
    for i, v in pairs (char:GetChildren()) do
        if v.ClassName == 'Accessory' or v.ClassName == "Hat" then
            v:Destroy()
        end
	char.ChildAdded:Connect(function(child)
          if child.ClassName == "Accessory" or child.ClassName == "Hat" then
            child:Destroy()
          end
        end)
    end
    end)

3 comments

0

Thanks!

0

That wasn't the question though, or related to the problem. Problem is hats/accessories take a moment to load in.

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