Is there a way to re-sort the player's backpack?

Hey, so I got feedback from a tool shop I made has some sorting issues with the backpack.

Let me explain how the shop works-

If you’ve ever played a simulator game before, in those shops where you have to buy the items numerically, and with the camera animating to each item, and you can only have 1 item of each genre equipped at a time, this is essentially what this is.

When the player equips a tool, I run a function looking for the old tool of that category in the player’s backpack, delete it, then create the newly equipped tool.

However, I received feedback from some one saying that the newly made tool isn’t in the correct spot, causing it to be hidden for mobile players. I think it was placed in the 4th slot even though the 3rd slot was available, if I’m not mistaken.

Is there any workarounds to this? Thanks. I can clarify if needed :slight_smile:

2 Likes

I’m positive this is happening because of the reason the old tool was placed in the 3rd slot and the new item was equipped before the old tool was destroyed. A way you can use to go around with this is removing everything in the player’s backpack then adding it back immediately after. You can do that with using :GetChildren to parent all tools to something else than immediately parent them back after. I’m not sure if there is any other way to re-arrange a player’s backpack with code. The only way I know until now was manually re-arranging them on the player’s side. I hope someone corrects me if I’m wrong here.

3 Likes

You’re not wrong, that’s pretty much exactly what’s going on. The backpack CoreScript will still register a slot as occupied where you’re not expecting it to due to the old tool, so it remains in an offset slot. Rearranging the backpack isn’t possible so you have to do something along the lines of making it look seamless in any possible way.

I believe that that one ninja simulator game does this very well in using a single tool instance and changing the properties of that rather than using separate tool instances for every new weapon you can buy. In this way, you keep the tool equipped, but purchasing an upgrade changes how the tool appears (both the icon and the handle). I don’t know how it’s done but it’s very seamless.

3 Likes

I 100% agree with what you’re saying. I saw many games use this technique before but never questioned why. It was around 2 years ago when I asked someone about it while I was a complete beginner and they told me that it was to prevent exploit, after that I never questioned it as I didn’t have any such issues before.

1 Like

I guess possibly a custom backpack HUD would be another option as well??

2 Likes