Market place service not working. Help!

My clicker script for prompting a user to purchase a gamepass is not working. I have tried looking at the roblox wiki, but haven’t found a significant difference in my code. Although, it doesn’t appear to be working.

Selection of the code.

Any kind of help would be appreciated!

2 Likes

In the future, please post your code on the actual thread as opposed to using a screenshot. You can do this by putting your code in a code block, either with three back ticks or using the code inserter in your post tools.

There’s not enough information on this thread either. Are you receiving some kind of error in your console? Have you verified that you’ve filled in the correct arguments for PromptGamePassPurchase? You need to grab as much detail as possible when filing a support request.

Please answer the following questions so I can help.

  1. Do you have any errors?
  2. Are you 100% sure v.Name is the correct gamepass id?
  3. Make sure your buttons are actually working by putting print("Test") before your if statement, print("Gamepass Test") before your gamepass purchase code and print("Devproduct Test") before your devproduct purchase code and tell me the if they print.

Hello, thanks for replying.
Yes, I have an “argument 2 missing or nil” error.

Try printing tonumber(v.Name) and see what it says.

Yes, I have an argument 2 missing or nil error.
I’m not sure how to go about solving this.

That means the second argument in the parameter is wrong/missing. In your case it is wrong. You need to put the gamepass id in there. Here is the example:

game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,123) -- Change 123 to the gamepass id

What are the names of the buttons? They have to be all numbers, don’t forget.

It can’t be the ID as this is a generic script I’m using for all the gamepass ID and dev products which are handled in one script. So v.name is applicable to all the gamepasses and dev products?

When you say buttons do you mean GUI numbers on the UI?


function GetName(ID)
   if type(ID) ~= "number" then
   	return
   end
   local sets = game:service("InsertService"):GetUserSets(ID)
   for k, v in next, sets do
   	if v.Name == "My Models" then
   		return v.CreatorName
   	end
   end
end

local function Sep(table,plr)
   for i,v in pairs(table) do
   	if type(v)=="userdata" then
   		v:Clone().Parent = plr.Backpack
   	elseif type(v)=="number" then
   		game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name).Value = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name).Value + tonumber(v)
   	else
   		if v:sub(0,2) == "W:" then
   			plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed + tonumber(v:sub(3))
   		else
   			plr.Character.Humanoid.MaxHealth = plr.Character.Humanoid.MaxHealth + tonumber(v:sub(3))
   			plr.Character.Humanoid.Health = plr.Character.Humanoid.Health
   		end
   	end
   end
end

local function SepQ(table,plr)
   for i,v in pairs(table) do
   	if type(v)=="userdata" then
   		v:Clone().Parent = plr.Backpack
   	elseif type(v)=="number" then
   		return
   	else
   		if v:sub(0,2) == "W:" then
   			plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed + tonumber(v:sub(3))
   		else
   			plr.Character.Humanoid.MaxHealth = plr.Character.Humanoid.MaxHealth + tonumber(v:sub(3))
   			plr.Character.Humanoid.Health = plr.Character.Humanoid.Health
   		end
   	end
   end
end

MarketplaceService.ProcessReceipt = function(receiptInfo)
   print(receiptInfo.ProductId)
   if Items[receiptInfo.ProductId] then
   	if type(GetName(receiptInfo.PlayerId)) == "string" then
   		wait()
   		local p5 = game.Players:FindFirstChild(GetName(receiptInfo.PlayerId))
   		wait()
   		Sep(Items[receiptInfo.ProductId],p5)
   	end
   end
   return Enum.ProductPurchaseDecision.PurchaseGranted		
end

game.Players.PlayerAdded:connect(function(p)
   if p~=nil then
   	for i,v in pairs(Gamepasses) do
   		if MarketplaceService:PlayerOwnsAsset(p,i) then
   			Sep(v,p)
   		end
   	end
   	wait(0.5)
   	p.CharacterAdded:connect(function(c)
   		for i,v in pairs(Gamepasses) do
   			if MarketplaceService:PlayerOwnsAsset(p,i) then
   				SepQ(v,p)
   			end
   		end
   	end)
   end
end) ``` 

This is the code in the dev product/gamepass handler

Put your code in between three ``` before the code, and three of those after the code.

1 Like

Is your code in a LocalScript?

If not LocalPlayer would not exist and cause the argument missing error.

I made a few open source scripts

Use this Gamepass Scripts, it should help you solve your problem.

1 Like

It looks pretty right, the only thing that I can find is that your missing a nil. Go watch some youtube videos about fixing errors. Or you can download a plugin that helps you! Hope this helps.

script.Parent.Buttons

Show me the name of the Buttons inside Buttons.

This worked however didn’t give me the 1million cash that was stored in the gamepass handler. Any ideas why?