Hello, I have been using DataSave for a script for a shop system that uses DeveloperProducts to get a currency used for the shop.
I get this error when I try to edit the currency
also when I purchase the Currency it prints it was purchased but nothing
is loaded, even when rejoining.
I also get “502 api HTTP 403” error
note that API services are on
This is how it is set up
Script for the Products for buying the currency:
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
–PROPERTY OF OMNIGEN DEVELOPMENT
local PreviousPurchases = DataStoreService:GetDataStore("PreviousPurchases")
local TEN_CASH = 501185648
local ONE_HUNDRED_CASH = 501185778
local FIFTY_CASH = 501185715
MarketplaceService.ProcessReceipt = function(receipt)
local ID = receipt.PlayerId…"-"…receipt.PurchaseId
local success = nil
local currency = game.Players.LocalPlayer.PlayerStats.Stats
pcall (function()
success = PreviousPurchases:GetAsync(ID)
end)
if success then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(receipt.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
else
if receipt.ProductId == TEN_CASH then
currency.Value = currency.Value + 10
end
if receipt.ProductId == ONE_HUNDRED_CASH then
currency.Value = currency.Value + 100
end
if receipt.ProductId == FIFTY_CASH then
currency.Value = currency.Value + 50
end
pcall(function()
PreviousPurchases:SetAsync(ID,true)
print("previouspurchases-working")
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
Script For the DataSave
local DataBaseStore = game:GetService("DataStoreService"):GetDataStore("testing-ds-pixel")
local statsholder = script.Stats
game.Players.PlayerAdded:Connect(function(NewPlayer)
local Key = "Player-ID:" … NewPlayer.userId
local GetSave = DataBaseStore:GetAsync(Key)
local DataBaseFolder = Instance.new("Folder", NewPlayer)
DataBaseFolder.Name = "PlayerStats"
for i, Stats in pairs(statsholder:GetChildren()) do
local NewStats = Instance.new(Stats.ClassName)
NewStats.Name = Stats.Name
NewStats.Value = Stats.Value
NewStats.Parent = DataBaseFolder
end
if GetSave then – dataload
for i, Stats in pairs(script.Stats:GetChildren()) do
DataBaseFolder[Stats.Name].Value = GetSave[i]
print (i, Stats.Name, Stats.Value)
print ("Loaded")
end
else – datasave
local StatsToSave = {}
for i, Stats in pairs (DataBaseFolder:GetChildren()) do
table.insert(StatsToSave, Stats.Value)
print (i, Stats.Name, Stats.Value)
print ("Saved")
end
DataBaseStore:SetAsync(Key, StatsToSave)
end
while wait(15) do --dataautosave
local StatsToSave = {}
for i, Stats in pairs (DataBaseFolder:GetChildren()) do
table.insert(StatsToSave, Stats.Value)
print (i, Stats.Name, Stats.Value)
print ("Saved")
end
DataBaseStore:SetAsync(Key, StatsToSave)
end
game.Players.PlayerRemoving:Connect(function(OldPlayer)
local Key = "Player-ID" … OldPlayer.userId
local StatsToSave = {}
for i, Stats in pairs (DataBaseFolder:GetChildren()) do
table.insert(StatsToSave, Stats.Value)
print (i, Stats.Name, Stats.Value)
print ("Saved")
end
DataBaseStore:SetAsync(Key, StatsToSave)
end)
end)