How to make a jigsaw inventory like in state of anarchy

I am planning to make a survival game that has an inventory system similar to that of state of anarchy which allows the player to fit items that are shaped irregularly into grids of inventory.

Unturned also has this feature.

My current idea is to detect the grids against the grid that the player clicks in a rectangular manner.

Is there any other simpler ways to achieve the same effect?
How should I export the data so it can be saved using datastore service?

2 Likes

You could make a grid that Items get snapped to, and then move the item to the closest slot it could be in, which can be lefttop for eas of use, then you check for every slot it currently hovers above after snapping and then place it can, else turn it back to its old spot.

For saving you just save its slot in the grid from top left, and when loading place everything back correctly.

UiGridLayout has a value called SortOrder, which can be used to sort the grids alfabeticly (like 1,2,3,4)

For the storage of inventory you could make a folder with the players name in replicatedstorage, and a folder for every grid. When putting an item in the inventory put a folder in the slot with the tool/item + a intvalue for size and a intvalue for width.