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

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

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)

4 comments

1

Local Script? You can't access ServerStorage with Local Scripts. Server Script? You can't use LocalPlayer in Server Scripts.

0

It suppose to print Player1 does not own the ID of... and it does not print that, which it should because I don

0

't own the Id

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.

1 answer

✓ Accepted answer

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!

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