Hey, I’m making a currency devproduct script, but the serverscript isn’t working.
AlvinBlox Tutorial I followed: https://www.youtube.com/watch?v=h92s4Xn26oc
This is the local script which works fine
local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
MarketplaceService:PromptProductPurchase(player, 1035581598)
print("sent the request to marketplace")
end)
This is the serverscript (if a put a print anywhere below the function it won’t print)
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
print("top")
local currencyName = "Gems"
local PreviousPurchases = DataStoreService:GetDataStore("PreviousPurchases")
print("got the previous purchases")
local FIFTEEN_GEMS = 1035581598
local EIGHTY_GEMS = 1035586681
local ONESEVENTY_GEMS = 1035587411
local THREESIXTY_GEMS = 1035588353
local NINEFIFTY_GEMS = 1035590075
local TWOTHOUSAND_GEMS = 1035590730
local BUY_PREMIUM = 1055143443
print("got all of the id's")
MarketplaceService.ProcessReceipt = function(receipt)
local ID = receipt.PlayerId.."-"..receipt.PurchaseId
print("got the ID")
local succes = nil
pcall(function()
success = PreviousPurchases:GetAsync(ID)
print("success")
end)
if success then
print("purchase has been granted")
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(receipt.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
else
if receipt.ProductID == FIFTEEN_GEMS then
print("adding fifteen gems")
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 15
end
if receipt.ProductID == EIGHTY_GEMS then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 80
end
if receipt.ProductID == ONESEVENTY_GEMS then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 170
end
if receipt.ProductID == THREESIXTY_GEMS then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 360
end
if receipt.ProductID == NINEFIFTY_GEMS then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 950
end
if receipt.ProductID == TWOTHOUSAND_GEMS then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 2000
end
if receipt.ProductID == BUY_PREMIUM then
player.PremiumPass.Owned.Value = true
end
pcall(function()
PreviousPurchases:SetAsync(ID,true)
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
Thanks