Sorry, I’m not going to provide a script for you as it would be long and quite complicated, but heres something you should check out to get started
You can use datastore modules such as ProfileService or create your own datastore system you can save and retrieve data from. Take a look at DatastoreService if you’re going to create your own.
For a backpack system, you’ll need to make your own. For example, at the start of the game, you can get the player’s inventory data from your datastore, and load them all into a backpack gui. To make stacks, you can check if an item has more than one, and you can merge them into one gui. If there are more than 10, tell the script to not make any more.
You might want to start on simpler things and not jump to advanced stuff like datastores.