How to create a table inside an array

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!

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

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.