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

How can I create a script that deletes your accessories and gives you new ones?

I want to create a script that removes the player's accessories and replaces them with certain other accessories if they're on a certain team.

For example, I'd want to give my soldier team a helmet and some other things. I'd need the script to delete the player's head accessories, and give them the accessories I want. I also want these to be catalog items, I have them in my server storage. I also want to be able to do this for any other accessories, like back and front accessories, etc.

PS: I already have a script that will change the player's clothing based on their team, but I'm not quite sure how I can do it with accessories.

2 comments

0

Can we play the game?

0

What?

2 answers

1 comment

0

Not the weapons. The player's accessories, like hats.

Simply remove all their accessories and then copy them from ServerStorage into the Player accordingly?

-- Iterate all instances in the character
for _,v in pairs(character:GetChildren()) do
	if (v:IsA("Hat") or v:IsA("Accessory")) then -- While the Hat class is deprecated, it might still be used which is why I added it just in case.
		v:Destroy()
	end
end

Note that this script simply removes all the accessories in a player's character, regardless of type.

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