This item is currently not for sale

In my new cafe game, I have a sign giving players the option to buy a rank, “Scooper” specifically.
This is the code:
local CLICK_BLOCK = script.Parent
local ITEM_ID = 6715637 --Replace the ID “1” with the ID of the item you want to sell. For example: 175085323

local Click = Instance.new(“ClickDetector”,CLICK_BLOCK)

Click.MouseClick:connect(function(p)
game:GetService(“MarketplaceService”):PromptPurchase(p,ITEM_ID)
end)

and this is a picture of it coming with the message.
image

The gamepass is visible on the game page, so I do not know why it doesn’t work in-game.
https://www.roblox.com/game-pass/6715637/Scooper-Rank

Could somebody help me figure out why it won’t load in-game and why it says it is off-sale?

If your cafe has a thumbnail: You got the wrong ID.

If your cafe does not have a thumbnail: It is still possible you got the wrong ID.

Also please use the code option indicated by </> as it makes your
code SO much easier to read.
1 Like

You have to use PromptGamepassPurchase for gamepasses, as the id is individual to the gamepasses. Instead of giving the id to your gamepass, you gave the id of a random place or item. (Gamepasses have a unique id system)

game:GetService("GamepassService"):PromptGamepassPurchase(player, gamepassId)

So, change your code too:

local CLICK_BLOCK = script.Parent
local ITEM_ID = 6715637 --Replace the ID “1” with the ID of the item you want to sell. For example: 175085323

local Click = Instance.new("ClickDetector",CLICK_BLOCK)

Click.MouseClick:connect(function()
game:GetService("MarketplaceService"):PromptGamepassPurchase(p,ITEM_ID)
end)
6 Likes

Sorry, I’m new to scripting and just trying to learn by messing around with scripts. After trying your code and exchanging some parts for others, it still does not work. It doesn’t even pop up with that “buy” gui. Should it be in a localscript instead?

May I ask why you are using click detectors? It’s much harder to pass through the FE barrier and it would be easier to create a GUI which fires the server.

All I did was give you code you can use to prompt a gamepass purchase, you have to figure out how to use it.

The MouseClick function has a parameter that returns the player who clicked. Read more about it here.

Edit: If this doesn’t work (I haven’t tested it) then try removing the code in the function and using a remote function and running the code on the client, but I’m pretty sure this should work.

The proper code would be (using the above code but fixing it)

local ITEM_ID = 6715637 --Replace the ID “1” with the ID of the item you want to sell. For example: 175085323

local Click = Instance.new(“ClickDetector”,CLICK_BLOCK)

Click.MouseClick:Connect(function(p)
game:GetService(“MarketplaceService”):PromptGamepassPurchase(p,ITEM_ID)
end)

@OneRubySky I don’t understand how this is relevant to the question at all or how it helps OP. A thumbnail isn’t related to an error in purchasing game passes at all - OP just used the wrong method.


@TyrantLords Make sure to mess around a little more in Studio or check API if you’re confused about something. AdvancedDrone pointed out that you can add a player parameter to ClickDetector to check who clicked.


@REALTimothy0812

That’s what OP wants to do - they want a ClickDetector that prompts a product.

Not sure what you mean by this at all?

Objectively untrue. Neither is easier to use over the other. They’re both simple mechanisms that you can use, depending on what it is you want and if it fits in with your game.

I’m not sure why you’d fire the server either even if you used a Gui - you can prompt game pass purchases right from the client itself. Getting the server involved is pointless overhead.

1 Like

I usually put a else after the Purchase just to make sure and re-put

game:GetService(“MarketplaceService”):PromptGamepassPurchase(p,ITEM_ID)

This might be dumb but maybe the reason it doesn’t work is because you didn’t replace the wrong quotes in @REALTimothy0812 's answer with the right ones?

local CLICK_BLOCK = script.Parent
local ITEM_ID = 6715637 --Replace the ID “1” with the ID of the item you want to sell. For example: 175085323

local Click = Instance.new("ClickDetector",CLICK_BLOCK)

Click.MouseClick:connect(function(plr)
    game:GetService("MarketplaceService"):PromptGamepassPurchase(plr,ITEM_ID)
end)

Hmm, the weird quotes were fixed by retyping them. I copied the original message, which seems to break the quotes for some reason. Anywho, should be fixed now.

I don’t use gamepasses, dev products, etc because I want to make games so that others can play. Forgive me but this was my thought:

If he got the wrong ID then a gamepass might show up from another game, hence the other thumbnail.
Even if it was the correct game, then a number could have been deleted or added.

I’m sorry my opinion wasn’t correct.

That mechanism only works when items on the catalog also have a corresponding AssetId which needs to be used in-game for something to work. Game passes, either on their legacy or current id system, do not support that functionality. Adding or subtracting numbers would not do anything.

The only time a game pass from another game would show up is if a game pass was a legacy one with an AssetId that matched the GamePass on its new id system.