Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Its a developer product. NOT A GAMEPASS Gooncreeper 98 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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]
0
Quoted: I am working on a script in ServerScriptStorage that gives you skips but PromptPurchaseFinished does not detect anything happening Gooncreeper 98 — 4y
0
in that terms Gooncreeper 98 — 4y
0
it means Gooncreeper 98 — 4y
0
it doesn't detect ANYTHING Gooncreeper 98 — 4y
0
THATS STILL NOT CLEAR, Do you MEAN IT DOESNT even EXECUTE THE SCRIPT ? be more precise and mark it solved VerdommeMan 1479 — 4y
Log in to vote
0
Answered by 4 years ago

[Answered] I figured it out.

Answer this question