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

Needing help with MarketplaceService.PromptPurchaseFinished, it is not working?

Asked by
FiredDusk 1466 Moderation Voter
7 years ago

If the player has the gamepass id, then I want them to get a weapon but it is not working. When you are in game and you press on the gui button, another gui is suppose to come up saying if you would want to buy it. It does not show up ;(

local Player = game.Players.LocalPlayer
local ID = script.Parent.GamePassID.Value

local MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.PromptPurchaseFinished:connect(function(Player, ID, isPurchased)
    if isPurchased then
        local Weapon = game.ServerStorage['Rocket Launcher']
        Weapon:Clone().Parent = Player.Backpack
        Weapon:Clone().Parent = Player.StarterPack
    else
        print(Player.Name.. " does not own the ID of  " .. ID)
    end
end)
1
Local Script? You can't access ServerStorage with Local Scripts. Server Script? You can't use LocalPlayer in Server Scripts. M39a9am3R 3210 — 7y
0
It suppose to print Player1 does not own the ID of... and it does not print that, which it should because I don FiredDusk 1466 — 7y
0
't own the Id FiredDusk 1466 — 7y
0
Get rid of line 1, which is the local player. And if it is a local script, copy and paste it into a server script. Vezious 310 — 7y

1 answer

Log in to vote
1
Answered by
FazNook 61
6 years ago

I know this is kinda late but there might be users with the same question. So all you are doing wrong is you did not actually prompt the purchase and you are directly asking the decision of the purchase. This can be fixed by: SERVER SCRIPT

local Player = game.Players:WaitForChild("FazNook",5) --Player; change this to whatever you are trying to  implement (.Touched or .MouseClick etc..)
local ID = 3141231 --ID of asset

local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService:PromptPurchase(Player,ID)
MarketplaceService.PromptPurchaseFinished:connect(function(Player, ID, isPurchased)
    if isPurchased then
        local Weapon = game.ServerStorage['Rocket Launcher']
        Weapon:Clone().Parent = Player.Backpack
        Weapon:Clone().Parent = Player.StarterPack
    else
        print(Player.Name.. " does not own the ID of  " .. ID)
    end
end)

Thank you!

Ad

Answer this question