I wanted to store a table within a string value and add new values to the list when the player buys an item that isn’t in the table.
I don’t know how to do a check using an if statement since it’s a string.
( " } " I’m putting using the script, to insert more values later )
I read about JSONDecode but I couldn’t use it for my problem.
Here is my current script:
script.Parent.MouseButton1Click:Connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent
local chars = player:WaitForChild("Data").Characters.Value.."}"
for _,v in pairs(chars) do
wait()
if v == "Goku" then
print("Already has the Character")
else
if player:WaitForChild("Data").Coins.Value >= script.Parent.Price.Value then
player.Data.Coins.Value = player:WaitForChild("Data").Coins.Value - script.Parent.Price.Value
player.Data.Characters.Value = player.Data.Characters.Value..', "Goku"'
print("Purchased")
end
end
end
end)
Thanks in advance for your attention.