Greetings, developers! I am making a game where inventories are involved. I keep the inventory within a LocalScript
as an array, in this format: (keep in mind the names aren’t what are actually there)
local inventory = {
{game.ReplicatedStorage.Placeables["item1"], 0},
{game.ReplicatedStorage.Placeables["item2"], 0},
{game.ReplicatedStorage.Placeables["item3"], 0},
{game.ReplicatedStorage.Placeables["item4"], 0},
{game.ReplicatedStorage.Placeables["item5"], 0},
{game.ReplicatedStorage.Placeables["item6"], 0},
{game.ReplicatedStorage.Placeables["item7"], 0}
}
Also, the number represents the quantity of that item. When sent to the server (via RemoteEvent
) for use in the Datastore, it failed to save, so I attempted a different method, because the fact that actual in-game items were in use within the array I decided to run a loop that basically converted it to just the names, like this:
local inventory = {
{"item1", 0},
{"item2", 0},
{"item3", 0},
{"item4", 0},
{"item5", 0},
{"item6", 0},
{"item7", 0}
}
I also tried using HttpService:JSONEncode()
and HttpService:JSONDecode()
to see if tables were even savable. But I found out that they must’ve been when I set my Datastore to a table using the DataStore Editor by sleitnick, because it loaded fine after I added a loop to wait until said table was loaded and sent to the client. I’m stumped. I’ve been trying for a few days and decided to come here for help. Help is very appreciated!