I’m working on an inventory system for my game and for a possibility for a variety of reasons it’s not allowing for me to add items to my dictionary in my datastore instead popping up with some weird string that doesn’t mean anything. How can I fix it so it properly adds to the dataStore and doesn’t add strange and unknown strings that don’t mean anything?
--Bindable functions I used to add the skin, more precisely the Red_SSS_Added
--If it helps I use Suphiis Datastore Module.
--Local functions I used to add the skins, in comments for AddSkinOrItem is what I used to add the skin.
--Do not worry about the RemoveSkinOrItem as it didnt function.
--Weird string popping up that im 99% sure doesn't mean anything unless the string is a uuid, but I cant tell.
Replace Game_Skins["Red SSS"] with just "Red SSS"
Your function AddSkinOrItem is supposed to take a datastore, and the name of a skin to add to the datastore, but you were calling it with the item’s dictionary, and not its name.
but the skin “Red SSS” is in the table game_skins.
I may have coded it a bit weird but the datastore mentioned is really just the Skins table that is saved via the datastore. How can I get the [“Red SSS”] table cloned to the player_skin_inventory?
Originally, I had assumed this wouldn’t work due to player_skin_inventory and Red SSS being a dictionary and typically table.insert being used for arrays but this worked. Thanks G
via the line above but without a Name causing the following to happen.
The 2 skins are 2 Red SSS’s but for some strange commonity do not display names. Any help on where to go from here? Im in studio as I speak trying to come up with a fix.
I check for the skin name via the following if statement;
The issue I seem to be having
table.insert
comes down to the simple fact that table.insert inserts data into tables as if said table was an array and not a dictionary. I’m attempting to find a way to insert data via an alternate method into the table as if it was a dictionary and not default to an array.
table.insert() uses numerical indices, if you want to check for items of a given name, you will have to use a loop to check for the Skin_Name value of each skin dictionary.
That setting is for changing how tables are printed in the output, with that setting on, printing a table will print its memory address rather than its contents.
However, if you have a dictionary which contains a value indexed by a table, the printed result will use the table’s hexadecimal address regardless. Example:
As far as I know, there is no way to change this behavior, even with the __tostring metamethod interestingly enough.
Alright i’ll change the way I check if an item is there. But as stated previously, no real way i’ve seen so far to import tables and data from the Game_Skins dictionary to the Skin_Inventory dictionary.
I’ve found the solution, turns out from my digging there is no real way to import a dictionary table into another dictionary so I’ve came up with a solution similar to you. Every time the Inventory is called, I will check for the skin and see if there if the skin’s name is there.