Datastore cant save array

I need to save the players loadout for my game, which includes the attachments added for each gun. But theres a problem, it says “cannot store Array in Datastore” when I try to save it.

is there any way I could save big arrays like this?

local loadout = {

["primary"] = "M4a1",
["secondary"] = "G18",
["melee"] = "Machete",
["gadgetone"] = "AmmoBox",
["gadgettwo"] = "nope nothing here",
["explosive"] = "grenades arent done yet",

attachments = {["primary"]={},["secondary"]={}},
    --above gets pretty big because it saves for each gun

current = nil;

}
3 Likes

What is the ‘Current’ Value usually?

The limit is 260k characters

You could also try turning the table into a json and saving that, you can then turn the json into a table when loading

Perhaps doing attachment1 and attachment2 instead of having it be in a table, and set current to false instead of nil. Just my guess.

What type is current when it’s not nil? If it’s an Instance or something similar, that is be your problem.

5 Likes

Yes, thats exactly what im thinking, turning it into a json turns any userdata into ‘null’ fixing it

ok yeah you were right. removed current and it worked. Current would have been the current gun that was equipped, and I was just lazy so I didn’t make a entirely new table without “current” lol

2 Likes