Iifebit
(Lifebit)
August 2, 2020, 8:16am
#1
So I am saving some data and I am going to Encode it into Json. The problem is I don’t know how to create tables into arrays.
Basically I want a table to be inserted into this array through a script.
local testarray = {
}
What I want after the script inserts it:
local testarray = {
["Creature"] = {
};
}
Any help is greatly appreciated!
un1ND3X
(ice)
August 2, 2020, 4:02pm
#2
local t = {}
-- insert a table within
t["Creature"] = {};
-- it now looks like
t = {
Creature = {}
}
or when trying to not invoke metamethods
local t = {}
rawset(t, "Creature", {})
or
local t = {}
table.insert(t, {})
-- looks like
t = {
{}
}
Why are you going to do that?
Everything’s encoded into a string already when saving to Roblox’s DataStores.
2 Likes
Iifebit
(Lifebit)
August 3, 2020, 2:48am
#3
Basically I am making a pokemon-type game and I’m saving the creature’s stats. I know you don’t have to encode it but I want to do it because it makes it a lot easier to load the data.