Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't this developer product transaction going through? (Access forbidden?) [HELP STILL NEEDED]

local MarketplaceService = game:GetService("MarketplaceService")
local buy = script.Parent
productID = 20518668

buy.MouseButton1Click:connect(function()
	MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, productID)
end)

So I've made a purchase button. This is a localscript within the purchase button. I have another NORMAL script that handles the transaction afterwards, of course.

The problem is that Roblox isn't letting it go through. I get this error: PurchasePromptScript: onAcceptPurchase() failed because HTTP 403 (HTTP/1.1 403 Forbidden)

So ROBLOX is kicking me out before I can do anything... It forbids access for the transaction. Please shed some light on this issue.

Oh, and in case you need it, here's my server-sided script that handles the transaction:

local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("countdowncreditservice")
local productID = 20518668

local buy = game.Players.LocalPlayer.PlayerGui.shopui.shopframe.creditwindow.credit


 
MarketplaceService.ProcessReceipt = function(receiptInfo)
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == productID then
				player.statistics.credits.Value = player.statistics.creditsValue + 1
				local key = "plry-"..player.userId
				local savedvalue = {player.satistics.credits.Value}
				ds:SetAsync(key, savedvalue)
				
				return Enum.ProductPurchaseDecision.PurchaseGranted
			end
		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

2 comments

0

Can you show us your Server-Sided script please? I believe we'll need it to give you assistance.

0

Sure thing.

1 answer

✓ Accepted answer

Mate, you cannot use LocalPlayer in normal scripts. On Line 5, you are attempting to assign a variable to "game.Players.LocalPlayer" which cannot be done in normal scripts. It also appears you are not using that variable anywhere in the script (Unless that's not the full script), so just remove Line 5.

Also, you spelled "statistics" wrong on Line 15, and forgot a period between "credits" and "Value" on line 13.. Lol. Not sure if those were intended or not.

local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("countdowncreditservice")
local productID = 20518668





MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == productID then
                player.statistics.credits.Value = player.statistics.credits.Value + 1
                local key = "plry-"..player.userId
                local savedvalue = {player.statistics.credits.Value}
                ds:SetAsync(key, savedvalue)

                return Enum.ProductPurchaseDecision.PurchaseGranted
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

Typos can be a real big issue in scripting. They get me a lot. :)

If I helped you, be sure to click the Accept Answer button below my character! :D

2 comments

0

Thanks!

0

You fixed a few problems, but I'm still getting the same error.

This discussion is preserved as it was. New answers, comments, and votes are closed.