Does anyone can teach me how to make a shop that save the tools you bought
i didnt publish my game cause thats the only thing i need to finish my game
(i can only save leaderstats but not tools)
1 Like
Those things are pretty similar aren’t they?
Let’s say you have a folder that stores all of the items that a player owns, you can then transform that folder of items into a string that you can save to your datastore the same as you would leaderstats, here’s an example:
toSave = {}
for _,item in pairs(player.Items:GetChildren()) do
table.insert(toSave,#toSave+1,item.Name) -- Add theiItem's name to the table
end
itemsString = game:GetService("HttpService"):JSONEncode(toSave) -- Convert table to string
You can then utilize this when the player spawns in along the lines of:
local itemsString = dataStore:GetAsync() -- replace with the DataStore you saved the string to
local itemsTable = game:GetService("HttpService"):JSONDecode(itemsString) -- Convert string to table
for _,item in pairs(itemsTable) do
local stringVal = Instance.new("StringValue") -- Create a new value and fill in the info
stringVal.Name = item
stringVal.Parent = player.Items
end
2 Likes
its complicated for me cause im kinda bad at scripting but imma try to understand it
1 Like
No need for JSONEncode roblox already does that when you store your data in roblox datastores
2 Likes