How to equip stacked items via inventory

Hi, so I have always wanted to know how to equip stacked items from a pet inventory for example, I have 2 rabbits and I want to equip both but my pet inventory only lets me equip 1. So can someone please tell me how I could make this possible.

My goal by the end of this post is to learn how to equip stacked items from an inventory.

I have tried calling the item by different names so instead of the 2 rabbits being called rabbits they would be called pet and pet 2 which I still had issues.

Thanks!

Wanting to help you figure this out, if possible send some more context or screenshots of some sort so we can get a better understanding of your current situation.

For example, what exactly do you mean by equipping stacked items?
How will they display / What are they meant to do?

If they are individual pets, why not store them separately?
Otherwise, you can use a for loop to equip all of the stored pets of a single type.

But, like @rabbiguy950 said, please provide more context / screenshots

So I am trying to make a pet equipping system where you could equip 3 pets, the issue is that if the player wants to equip a duplicate of an item the script picks one of the of the duplicates as they both have the same name. So I am trying to see if anyone could help me allow the player to equip duplicates of the pet instead of only equipping one and saying that the duplicate is equipped as well.

Can you please share your current code? It’s easier to locate your problem with visuals.

But otherwise, it seems like you need to keep track of how many of that pet is equipped, and check to make sure that the player has x of those pets.

For the most part it seems like you already have certain requirements set in place which prevent a player from equipping two of the same pet. If that is the case you’ll have to figure out where that is set up in order to remove it. If that is not the case, then I would suggest trying to rename them to rabbit1 and rabbit2 for example and run a for loop to actually equip them. Unfortunately though as @XlxLiveLivelyxlX said, it’s hard to give any in depth assistance without the code itself.

Rather than saving the pets by name, I would create a unique ID (the ID only needs unique for the player, not unique for all pets of all players) for each new pet, and store them individually rather than stacking them.

1 Like

do you know how I can accomplish creating a unique ID for each pet?

One simple way to do it is to save the number of pets. For example:

The player joins the game for the very first time, so let PetNum = 0.

The very first pet you get is a bunny, so let PetNum = PetNum + 1, and set the bunny’s ID to PetNum (which is 1; you can save this in a IntValue or however you so choose).

Next they get a dog, and again, let PetNum = PetNum + 1, so the dog’s ID would be 2.

Now they don’t want the bunny anymore, so they remove it from their inventory. PetNum would remain at 2, because the ID 1 has already been used, even if they don’t own the pet anymore.

2 Likes

Thank you very much :slight_smile:

1 Like