What Value do i use to Store Tables in it?

Hello!

I was wondering how can i store my tables in Value of certain object.
for example, in IntValue i can store numbers, in StringValue i can store strings.
and i dont know where in what values i can store tables.

So far i tried in StringValues - It doesnt work.

Is there any solution, perhaps its not even possible?

There is no such value for storing tables, but there is actually way you can do it with string values if you JSONEncode a table and then store it inside of a StringValue

This is what this code outputs
image

image

1 Like

Is there a way to UN JSONEncode it?

local PlayerValues = StringValue.Value -- doesnt work this way

HttpService:JSONDecode(StringValue.Value)

1 Like

The Batman is all over this one.
{} is all you need to store values in a table.

local HttpService = game:GetService("HttpService")

-- Example table to store
local myTable = {1, 2, 3, a = "hello", b = "world"}

-- Serialize the table to a JSON string
local jsonString = HttpService:JSONEncode(myTable)

-- Store the JSON string in a StringValue
local stringValue = Instance.new("StringValue")
stringValue.Name = "MyTableData"
stringValue.Value = jsonString
stringValue.Parent = game.Workspace  -- Adjust the parent as needed

-- Retrieving the table from the StringValue
local retrievedJsonString = stringValue.Value
local retrievedTable = HttpService:JSONDecode(retrievedJsonString)

-- Accessing values from the retrieved table
print(retrievedTable.a)  -- Output: hello
print(retrievedTable[1]) -- Output: 1
1 Like