How do I find the difference between 2 tables for client updating purposes?

Hello!

My current situation is I’m working on Inventory&Backpack system, but my current way of updating the client is take the entire table from the data store cache (I use datastore2, btw) and send it to the client via Remote Event and let the client deal with the data, that is, check weather something already exists or not doesn’t.

So this called for optimization at least for the Inventory side, since backpack is pretty constant data size. My idea was to run one in pairs loop for one table in another in pairs loop for the other one, but the thing is if I do value1 ~= value2 - it’ll be true for the most part, since it’ll go through every item in the second table, so my fix was to check for the index1 == index2 since both tables are nearly identical, but then it would prevent me from adding/removing items from the tables without any issues…

So that’s where i’m at now… any advice is appreciated, I just want to get closer to a functioning inventory…

TY for reading!

Edit: forgot to mention that the 2 tables are one returned from the datastore2’s OnUpdate function, and the other is a copy of that, that is going to be updated.

2 Likes