How to make a datastore shop?

Hi, your best way going around this would be doing something of the following:

local DataStoreService = game:GetService("DataStoreService")
local ShopData = DataStoreService:GetDataStore("Shop")
local player = [wherever you get your player from]
local success, currentitems = pcall(function()
	return ShopData:GetAsync(player.UserId)
end)
 

if not currentitems then
local currentitems = {"Newitem"}
else
table.insert(currentitems,"Newitem")
end
local success, newitems = pcall(function()
	return ShopData:UpdateAsync(player.UserId, currentitems)
end)

@Calagoz can you explain what its doing? Like this

local DataStoreService = game:GetService("DataStoreService") --getting datastoreservice from the game```

Data Stores (roblox.com)

1 Like