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
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