Advice on how I should store values

So I have a folder that contains IntValues numbered from one to a certain amount and the value of those IntValues is the amount of that [number] item a player owns. By the name of the folder, you can probably guess what I’m trying to do.
image
My question is, should I store values in a module this way

local Module = {}

Module.Values = {
	
	[1] = { -- Represents the number in the pet folder
		
		Value1 = 1; -- Name
		Value2 = 2; -- Definition
		Value3 = 3; -- Etc
		
	};
	
	[2] = {

		Value1 = 1;
		Value2 = 2;
		Value3 = 3;

	};
	
	[3] = {

		Value1 = 1;
		Value2 = 2;
		Value3 = 3;

	};
	
	[4] = {

		Value1 = 1;
		Value2 = 2;
		Value3 = 3;

	};
	
	[5] = {

		Value1 = 1;
		Value2 = 2;
		Value3 = 3;

	};
	
}

return Module

Or is there a simpler way of doing it?

Or is my way a bad idea/won’t work?

1 Like

It will work, just make sure to name them correctly, and save the arrays into datastores!

You should store them in scripts versus instances. Indexing instances and retrieving their values takes longer than script indexing. Definitely switch.

Don’t spread miss-information, that is not true. Both of them have the same speed, even if they differ, the performance difference is negligible, this is not worth the switch but storing values in tables is generally preferable.

Do you have a source where I can see that they have the same speed, or are you going on a limb? Waiting for object values to replicate and to index them takes longer than putting them in script tables.

While you are correct the difference is probably negligible, the OP didn’t really state to keep out negligible information, this is Code Review after all.

Also to add on, @MarwinRamz, you’re storing instance values under the player instance. This is considered bad practice because if you ever need the data moments later after the player leaves, it won’t be there for you to access anymore. I suggest switching for a cleaner, more performant and more efficient way of handling data.

There’s no performance differences and is generally better practice to store in the other values like “stringvalue”, “intvalue”,“objectvalue” etc if you plan to use it in another script. The only other better way is to use a module script, however it isn’t the best practice to do that.

Do you have a source where I can see that they have the same speed, or are you going on a limb? Waiting for object values to replicate and to index them takes longer than putting them in script tables.

No, this is completely false. PetsFolder contains object values which don’t need to be replicated except to the client (when they are created), the server doesn’t have to wait for the values to replicate because they are literally being created in the server.

To test the performance, do that your self.

While you are correct the difference is probably negligible, the OP didn’t really state to keep out negligible information, this is Code Review after all.

You shouldn’t point out unnecessary points when code reviewing.

That is bad practice yes, but storing them in tables isn’t performant but effective.