I used a tutorial to create a ProccessReceipt function, but whenever I hit f5 to test it in studio, it tells me that ReceiptInfo.PlayerId is nil. I’m not sure how to fix this. Here is the script:
function processReceipt(ReceiptInfo)
local plr = Players:GetPlayerByUserId(ReceiptInfo.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if plr and LoadedData then
print("Bought A Donation")
AmountDonated = AmountDonated + 10
local Suc, Err = pcall(function()
if ReceiptInfo.ProductId == SD then
DonationODS:SetAsync(Player.UserId.."Donated",AmountDonated + 10)
elseif ReceiptInfo.ProductId == MD then
DonationODS:SetAsync(Player.UserId.."Donated",AmountDonated + 25)
elseif ReceiptInfo.ProductId == BD then
DonationODS:SetAsync(Player.UserId.."Donated",AmountDonated + 100)
elseif ReceiptInfo.ProductId == HD then
DonationODS:SetAsync(Player.UserId.."Donated",AmountDonated + 1000)
end
end)
if Suc then
print("Successfully Saved Donation")
end
if Err then
print("There was an error saving your donation")
warn(Err)
end
end
print(AmountDonated)
SaveData()
return Enum.ProductPurchaseDecision.PurchaseGranted
end