How to stop the purchasing infinite amount of the same gamepass?

I have a button that allows you to purchase a boombox gamepass, where it gives you a boombox (go figure). But it allows you to keep purchasing it over and over again, giving you more and more boomboxes at the price of 500 R$. Is this just how Studio test purchasing works or is there something wrong with this script?

This is the local script located inside of the shopMenu ScreenGui. I have another regular script inside of the button itself that focuses on giving the player the boombox, I’m 99% sure it has nothing to do with the issue.

local MarketplaceService = game:GetService("MarketplaceService")
local ServerStorage = game:GetService("ServerStorage")

local MainFrame = script.Parent.Frame
local player = game.Players.LocalPlayer

local GP_bb = MainFrame.ScrollingFrame.boombox.bb_button
local ID_bb = 14537695 -- boombox gamepass 500$


GP_bb.MouseButton1Down:Connect(function()
	local sucess, message = pcall(function()
		hasPass4 = MarketplaceService:UserOwnsGamePassAsync(player.UserId, ID_bb)
	end)

	if hasPass4 then
		print("Player already has BOOMBOX gamepass")
	else
		MarketplaceService:PromptGamePassPurchase(player, ID_bb)
		print("Initiated BOOMBOX Gamepass Prompt")
	end
end)

Any help is appreciated, thanks!

1 Like

Have you attempted to make the GamePass 1 R$ and buying it online?

1 Like

I don’t think userownsgamepassasync works on test purcheses. Try it in game with real gamepass(make it cheap of course)

1 Like

I can try that real quick, let me see.

Thus far, it’s not working at all, I’m not even getting the boombox when I spawn into the game…?

Edit: Forgot to re-enable a script. Just a sec.

Getting error while trying to spawn in with Boombox, “StarterPack is not a valid member of Player…”

I don’t want to drag you into my mistakes, but got any idea what’s going wrong?

Here’s the script:

--SERVICE LOCALS--
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local player = game.Players.LocalPlayer

--ID LOCALS--
local ID_bb = 14537695 -- boombox 500R$

--GEAR LOCALS--
local Boombox = game.ServerStorage.Gear.BoomBox

--BOOMBOX GAMEPASS--
game.Players.PlayerAdded:Connect(function(player)
	local success, message = pcall (function()
		hasPass4 = MarketplaceService:UserOwnsGamePassAsync(player.UserId, ID_bb)
	end)

	if hasPass4  then
		print("Player has BOOMBOX gamepass")

		Boombox:Clone().Parent = player.Backpack
		Boombox:Clone().Parent = player.StarterPack

	end
end)

Edit: My bad, fixed it :joy:, have to use GetService(“StarterPack”)

local StarterPack = game:GetService("StarterPack")

It is StarterGear not StarterPack.

1 Like
if hasPass4  then
		print("Player has BOOMBOX gamepass")

		Boombox:Clone().Parent = player.Backpack
		Boombox:Clone().Parent = player.StarterPack
	end

your script here shows that you own gamepass.
You also need to check if the player owns the gamepass while pressing the purchasing button

1 Like

Any idea how to do that? Just jumping into gamepasses and all that jazz, lots of new things to learn here.

Did you read the whole thing through from the Roblox API?

1 Like

I certainly did. I didn’t see anything about “while.”

Have you checked if the asset was a GamePass or a Developer Product? Dev Products can be purchased multiple times while GamePasses can only be purchased once (as long as the user doesn’t delete the GamePass from their account and buy it again).

1 Like

I checked that as well. Definitely a gamepass. I’m thinking it’s Studio thing, but I haven’t gotten to work in-game. Plus, I just realized RoSync virus is back in my game, so I’m going through deleting that. Maybe that’ll maybe make a difference, I don’t know.

Edit: Now GetService(“StarterPack”) isn’t working anymore…?