I have a boombox gamepass script which gives you the boombox right after you buy it, however it also gives you the boombox if you press "cancel"

Someone help

local MarketPlaceService = game:GetService("MarketplaceService")

local GamepassId = 28475378
local Tool = script.Boombox

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
	local ToolClone = Tool:Clone()
	ToolClone.Parent = plr.Backpack
	
	end)

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
			local ToolClone = Tool:Clone()
			ToolClone.Parent = Player.Backpack
		end
	end)
end)

Actually if you click on anything in my shop gui it gives you the boombox https://gyazo.com/6367854e614b1d01b25a7c880458b3d0

local MarketplaceService = game:GetService("MarketplaceService")
 
MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
	if isPurchased then
		print(player.Name .. " bought an item with AssetID: " .. assetId)
        --give them the item
	else
		print(player.Name .. " didn't buy an item with AssetID: " .. assetId)
	end
end)

1 Like
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GamepassId = 28475378
local Tool = script.Boombox

MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player, PassId, DidPurchase)
	if PassId == GamepassId then
		if DidPurchase then
			local ToolClone = Tool:Clone()
			ToolClone.Parent = Player.Backpack
		end
	end
end)

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
			local ToolClone = Tool:Clone()
			ToolClone.Parent = Player.Backpack
		end
	end)
end)

The “.PromptGamePassPurchaseFinished” event is for handling gamepass purchases, you were using the variant for developer products instead.

it says in the title gamepass though?

Yeah, I must’ve attached the wrong explanation to the wrong code, his issue is occurring because he omitted the “was purchased” parameter which represents whether or not the user purchased the gamepass.

1 Like