generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: "DataStores cannot be arrays"

Previous Thread :: Next Thread 
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
01 Aug 2016 10:45 PM
Since when roblocks

since
wen
Report Abuse
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
01 Aug 2016 10:48 PM
As for a question, I'm trying to save player inventories with 60 slots. They go something like this:


{
{"Boots", "Boots of Undying", 3}
{"Hat", "Hat of Undying", 3}
(58 more things like that)
}

Why can't I save that?
Report Abuse
unwarranted is not online. unwarranted
Joined: 05 Jun 2009
Total Posts: 1087
01 Aug 2016 10:49 PM
because that's a 'mixed' array.
http://wiki.roblox.com/index.php?title=Data_store
"Tables with mixed list / record style will be cut off
Lua tables which have a mixed style will not be saved correctly. This is a known issue."


mom wheres the spaghetti | R$19,427
Report Abuse
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
01 Aug 2016 10:55 PM
So should I use tostring on all the numbers and then tonumber() when reading them back?
Report Abuse
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
01 Aug 2016 11:08 PM
OK, so now I'm *trying* to save it like this:

{
{"Boots", "Boots of Undying", "3", "1"}
}

The final "1" is for true and false.
I got the error:

"Arrays cannot be stored in DataStores"
Report Abuse
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
01 Aug 2016 11:11 PM
00:07:07.331 - Cannot store Array in DataStore
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
01 Aug 2016 11:11 PM
That has nothing to do with the values.

The problem is mixing arrays with dictionaries. Tables are stored as JSON, JSON cannot represent it.


@OP

Post the code. Datastores can save arrays just fine.
Report Abuse
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
01 Aug 2016 11:14 PM
function CompileInventory(PLAYER)
local INVENTORY = InventoryData:FindFirstChild(PLAYER.UserId)
local INV_COMPILED = {}
for i = 1, 60 do
local ITEM = INVENTORY[i]
local ITEM_COMPILED = {}
if (#ITEM:GetChildren() > 0) then
--for _,ITEM in pairs(ITEM:GetChildren()) do
local TYPE, NAME, LEVEL, ASSET, SELL_PRICE, EQUIPPED = ITEM.Type.Value, ITEM.ItemName.Value, ITEM.Level.Value, ITEM.AssetID.Value, ITEM.SellPrice.Value, ITEM.Equipped.Value
table.insert(ITEM_COMPILED, TYPE)
table.insert(ITEM_COMPILED, NAME)
table.insert(ITEM_COMPILED, tostring(LEVEL))
table.insert(ITEM_COMPILED, tostring(ASSET))
table.insert(ITEM_COMPILED, tostring(SELL_PRICE))
if (EQUIPPED == true) then
table.insert(ITEM_COMPILED, "1")
else
table.insert(ITEM_COMPILED, "0")
end
--end
end
table.insert(INV_COMPILED, ITEM)
end
return INV_COMPILED
end


The table returned from that function is what I'm saving.
Report Abuse
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
01 Aug 2016 11:32 PM
b1


choo choo
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image