How to Randomly Pick Something From a List and Give it a Custom Name

How would I give the assets received in this script their own custom names? The names would be Hat1, Hat2, and Hat3 so the game has something to refer to each of them. If the player only has 2 hats equipped then there would only be two things needing to be named and if they have none then there would not be any. I don’t know how to do this especially because the amount they will have if any isn’t for sure

for _, asset in pairs(game.Players:GetCharacterAppearanceInfoAsync(player.UserId).assets) do
			if asset.assetType.name == "Hat" then
				local Template = game.ServerStorage.AvatarSystem.ItemEquippedTemplate:Clone()
				Template.Parent = player.PlayerGui.MainGui.Avatar.Frame.Wearing
				Template.Id.Value = asset.id
				Template.Icon.Image = 'rbxthumb://type=Asset&w=150&h=150&id='..tostring(asset.id)
				player.Avatar.Hats.Amount.Value = Value+1
			end
		end

Where exactly does the game refer to the hats? If you need to refer to them by Hat1, Hat2, and more, where does the game do that? If it is from the player’s character, you will need to rename it. Although, depending on overall what you’re attempting to do, there might be a better solution.

1 Like

It gets them from the player’s avatar when they join for the first time and then it puts them into the avatar editor as little bubbles and when a player clicks the bubble it removes the hat