Getting dataStore:-
local shopUi = plr.PlayerGui:WaitForChild("shopGUI")
local shop = shopUi.Shop
local folder = shop.butttons
local s,e = pcall(function()
return ownedStore:GetAsync(plr.UserId)
end)
if s then
for i,v in pairs(folder:GetChildren()) do
if v.Name == ownedStore:GetAsync(plr.UserId) then
v.owned.Value = true
end
end
else
warn(e)
end
end)
Saving the dataStore:-
game.ReplicatedStorage.BuyEvent.OnServerEvent:Connect(function(plr,pizza)
local shop = plr.PlayerGui.shopGUI.Shop
local leaderstats = plr.leaderstats
local coins = leaderstats.Coins
local inv = plr.Inventory
local multi = inv.Multiplier
local price = pizza:GetAttribute("price")
local multiadded = pizza:GetAttribute("multiplier")
local owned = pizza.owned
owned.Value = true
coins.Value -= price
multi.Value = multiadded
multiStore:SetAsync(plr.UserId,multi.Value)
local s,v = pcall(function()
return ownedStore:GetAsync(plr.UserId)
end)
if not s then
ownedStore:SetAsync(plr.UserId,pizza.Name)
else
ownedStore:IncrementAsync(pizza.owned.Value)
end
end)