Null Table Values

Heya Devs,

I am trying to figure out how to save values that track whenever purchase something from the in game shop. These values also are a major key in my inventory system.

Basically each shop item has a value, and if the item is bought, then the Value is set to true and the player will have it in their inventory GUI, and will not be able to buy the item from the shop again.

In order to save these values, I created a table within my save script:

local anim = {}
	for i, v in pairs(inventory.Animations:GetChildren()) do
		table.insert(anim,i,v)
	end

I am now fairly certain that this is not working as I intended. I imagined that this would just save a copy of the value that I would be able to use later, however when checking, each of the values within the table say null.

I am not sure if I coded something wrong or if what I am trying to do is just not possible; but I need to somehow save the name of the value, and what its value is within the table.

If I’m reading this correctly it looks like you want anim to be a table of everything contained in inventory.Animations. If so, the :GetChildren() method already returns an array that you can store directly into anim:
local anim = inventory.Animations:GetChildren()

This may not solve your problem, but it’s worth a try, and if not, I’d ask what exactly is contained in inventory.Animations. Is it boolvalues?

This did not seem to fix my problem.

But yes, there is a boolvalue for each animation that is within the shop:
When the player buys an animation, its boolvalue is set to true. When set to true, the player cannot buy the animation again, it changes the shop GUI so that-that item says purchased, and it added a clone of that that item into their inventory GUI so that they can equip it whenever they want.

And you tested it by looping through anim and printing each item?

Yes well I actually printed my SavedData which is how I know that all of the saves say nil.

For the most part, I believe that I have figured out my solution.

I am only going to save the name of the value, if it is True. I tested it, and the name of the value does save.

If there is a saved value, then it will index and find the already made value and make sure it is set to true as well.