I wanting to keep my players inventory clean and as ‘empty’ as possible, so when the player leaves I wanna basically shorten their inventory down.
Few key points
- Every 5 slots is a row/line
- Slots 1-30 should remain untouched
So quick example, let’s say this is the players Inventory when they leave.
local Inventory = {
[1] = {},
[2] = {},
[3] = {},
[4] = {},
[5] = {},
[6] = {},
[7] = {},
[8] = {},
[9] = {},
[10] = {},
[11] = {},
[12] = {},
[13] = {},
[14] = {},
[15] = {},
[16] = {},
[17] = {},
[18] = {},
[19] = {},
[20] = {},
[21] = {},
[22] = {},
[23] = {},
[24] = {},
[25] = {},
[26] = {},
[27] = {},
[28] = {},
[29] = {},
[30] = {},
[31] = {},
[32] = {},
[33] = {},
[34] = {},
[35] = {},
[36] = {},
[37] = {},
[38] = {Id = "25", Quantity = 12},
[39] = {},
[40] = {},
[41] = {},
[42] = {},
[43] = {},
[44] = {},
[45] = {}
}
So slots 1-30, do not get touched, regardless if they empty or not.
Slots 31-35 (all of those slots are empty, so remove them) Slots 36-40 have an item (38) so we keep them, slots 41-45 are all empty, remove them.
However, when removing 31-35, 36-40 should move down and take their place. I don’t want
local Inventory = {
[1] = {},
[2] = {},
[3] = {},
[4] = {},
[5] = {},
[6] = {},
[7] = {},
[8] = {},
[9] = {},
[10] = {},
[11] = {},
[12] = {},
[13] = {},
[14] = {},
[15] = {},
[16] = {},
[17] = {},
[18] = {},
[19] = {},
[20] = {},
[21] = {},
[22] = {},
[23] = {},
[24] = {},
[25] = {},
[26] = {},
[27] = {},
[28] = {},
[29] = {},
[30] = {},
[36] = {},
[37] = {},
[38] = {Id = "25", Quantity = 12},
[39] = {},
[40] = {},
}