In game purchase error

I used a script someone on this site gave me and it gave me this error, maybe it’s because I’m in studio or how can this be fixed?

local MSS = game:GetService(“MarketplaceService”)

MSS:PromptGamePassPurchase(player,idhere) – put your id in the “idhere” section

You have no id in here:

Put your gamepass id in where it says, (player, idhere)!

Maybe that is causing the problem?

Place this script under a GUI Button Object. It should be a LocalScript.

local MarketplaceService = game:GetService("MarketplaceService")
local player = game:GetService("Players").LocalPlayer
local GamepassId = 000000000

MarketplaceService:PromptGamePassPurchase(player, GamepassId)

Your previous script has probably caused a lot of errors.


I’m not sure if you can buy something using a Local Player but it should work.

If something will not work for you, open this place and correct your mistakes. Place:
Gamepass Button Example - Roblox.rbxl (24.5 KB)

GamepassId (some random numbers) can be found in a link to Gamepass in your web browser.

Also make sure to try it in a real game. I don’t think studio works with purchases.

Studio does work with purchases, just have to make sure its enabled in settings.

1 Like

I need it in a part though, I don’t want it in gui, also its not a gamepass but a in game purchase, those things u can buy multiple times

No, I just removed the id to post it

If I am right, you probably want it to prompt purchase to the player who touches the specific part? Then you will have to get Player from the character & then prompt the purchase for that player.

Was there any server-side scripts changing MarketplaceService.ProcessReceipt?

If so, it probably did:

MarketplaceService.ProcessReceipt = function(receptInfo)
    -- blah blah...

    return Enum.ProductPurchaseDecision.NotProcessedYet

This is right, except I don’t want them to touch but click a part to purchase

Is your post help related or a request? If it’s a request, you can post on another topic.

So your script seems to be having the problem, because you want to Prompt For a Developer product purchase, so you need to be using PromptProductPurchase function of MarketPlaceService, and pass in the Player instance & product Id respectively

Well, I basically can’t script but I already have this script with just an error and need help with that

So what needs to be Changed about the script

Well, I don’t really want to Spoon Feed you with all the code, but I have guided you with what needs to be Used for products that can be bought multiple times, which you want.

For example code can be like this

local ClickDetect = script.Parent:FindFirstChildOfClass("ClickDetector")
local ProductID = 000000 -- ID of your product is required
local MarketPlaceService = game:GetService("MarketplaceService")

   MarketPlaceService:PromptProductPurchase(player, ProductID)

Then if you want to check if someone has bought this, you would want to use ProcessReceipts as told by @Trizxistan earlier in the thread

1 Like

It would be best if you didn’t try to get Player from the MouseButton1Click event. You can make a different variable Player and remove the argument Player from that event. To get the Player via gui (not with ClickDetector), refer to using Players.LocalPlayer

Here’s an example:

local Player = game:GetService'Players'.LocalPlayer
local TextButton = script.Parent
local MarketplaceService = game:GetService'MarketplaceService'


P.S. I realized how you had ‘player’ as an argument, not ‘Player.’ You can just uncapitalize the letter P if you want to match the new variable ‘Player’.

Actually, he is using a click detector inside a part. So I guess player is the first arguement passed from ClickDetector.MouseClick function

Ill test yours and @WaterJamesPlough ‘s code when I’m back on my laptop, thanks!

1 Like
local Clicker ="ClickDetector", script.Parent)
local MarketplaceService = game:GetService'MarketplaceService'
local idhere = 12013123 -- put the gamepass id here

try this, also put the script inside of the part

1 Like

So when I’m back I’ll test the codes you guys send me but a question, how am I sure it works? What will be on the screen? The general purchase screen or something saying “error you can’t be in studio” or something