I am working on my game, and I am going to add a pet upgrade feature! There are multiple pets with different kinds of upgrades, resulting in a lot of different sets of information to be put in a player. Now, I could put like 50 different int values in the player for each thing, but that obviously is a lot and very time consuming. I know you can put stuff in the player like this:
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = player
But is there a way to make it a table value? It also needs to be put in a datastore so that also complicates things…
You can use a string value to store tables and use JSON to Encode/Decode the table to string format:
local HS = game:GetService("HttpService")
local MyTable={Coins=0, XP=0}
MyStringVal.Value=HS:JSONEncode(MyTable) -- Encodes to String
MyTable=HS:JSONDecode(MyStringVal.Value) -- Decodes back to Table
If I was you I will save every ‘pet feature’ with ID to modulescript (table) and specify everything in there and then you will make table as others stated where you gonna store the ID of the pet feature.