I would like to know how I can make a bracket set of [ ] in a string, for example
a string’s value to be [“123”,“123”]

see how there’s the [ brackets surrounding them.
The Problem is that I don’t know what the correct coding is in order to achieve this effect, i’ve tried setting the string value but it errors


The '
is your friend. : )
YourValue.Value = '["123","123"]'
2 Likes
If you don’t know the exact contents of your array beforehand, you might be interested in encoding it as json (which turns it into a string) and decoding it when you want to read it (which turns it back into an array):
local http = game:GetService("HttpService")
local myArray = { "123", "123" }
-- when you want to save it:
local asAString = http:EncodeJson(myArray)
TraitKeeper.Value = asAString
-- later when you want to read it:
local backAsAnArray = http:DecodeJson(TraitKeeper.Value)
1 Like
You can use [[
or '
:
value.Value = [["123","123"]]
Thank you, I have another question
How do I insert strings into the brackets?
If I have a string
myValue.Value = ‘[ ]’
how do I insert “123” , “123” into it so it becomes
print(myValue.Value) --[“123”,“123”]
?