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

How do I use ProcessReceipt and how would I use it to detect a developer product bought?

I am working on a script in ServerScriptStorage that gives you skips but PromptPurchaseFinished does not detect anything happening. I have the prompt for the developer product be given by a local script in the player gui as you buy the skips from a player gui. Here is my script in ServerScriptService.

SkipGampess = {{1022226653, 5}, {1022246676, 10}, {1022248516, 25}, {1022247497, 50}, {1022247956, 100}}
game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(plrId, productId, purchased)
	print("PurchaseDetected")
	if purchased then
		print("WasPurchsaed")
		for i, v in pairs(SkipGampess) do
			if SkipGampess[1] == productId then
				for a, b in pairs(game:GetService("Players"):GetChildren()) do
					if b.userId == plrId then
						v:WaitForChild("playerVariables"):WaitForChild("Skips").Value =  v:WaitForChild("playerVariables"):WaitForChild("Skips").Value + v[2]
					end
				end
			end
		end
	end
end)

3 answers

I would prefer using this script as I have used this in my game

script.Parent.MouseButton1Click:Connect(function() -- function for the gamepass purchase
game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,-- Number of gamepass --) -- Using the marketplaceService and PromptGamePassPurchase for buying the gamePass.
end)

local player = game.Players.LocalPlayer -- Create variable for player
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,-- Number of gamepass --) -- Checking if the player owns the gamePass

if ownsGamepass then
	 -- The functions for skipping the stage--
end

I know you know about roblox scripting but still writing to make it easy for you.

1 comment

0

Its a developer product. NOT A GAMEPASS

on line 7 shouldnt it be SkipGampess[i][1] or v[1], you cant compare and id with an array

also game.Players:GetPlayers() use this to loop over the players

and line 10 u can turn into

    v:WaitForChild("playerVariables"):WaitForChild("Skips").Value +=  v[2]

5 comments

0

Quoted: I am working on a script in ServerScriptStorage that gives you skips but PromptPurchaseFinished does not detect anything happening

0

in that terms

0

it means

0

it doesn't detect ANYTHING

0

THATS STILL NOT CLEAR, Do you MEAN IT DOESNT even EXECUTE THE SCRIPT ? be more precise and mark it solved

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