Why isn't this DeveloperProduct Script working?

Greetings!

So i’m currently having an issue with the codes below. When I click on the Gamepass button, nothing happens.
Why?


There are 2 scripts ;

  • one is a Local Script inside a frame inside StarterGui
  • the other one is a Server Script inside ServerScriptService
Local Script
-- Services

local MarketPlaceService = game:GetService("MarketplaceService")

----------------------------

-- Variables

local player = game.Players.LocalPlayer

local InventorySlotsButton = script.Parent:WaitForChild("InventorySlots"):WaitForChild("Buy")

local IDs = {

1272826368, -- +3 Inventory Slots

}

----------------------------

-- Code

local function PurchaseDeveloperProduct(Key)

local ID = IDs[Key]

MarketPlaceService:PromptProductPurchase(player, ID)

end

PurchaseDeveloperProduct.MouseButton1Click:Connect(function()

PurchaseDeveloperProduct(1)

end)
Server Script
-- Services

local MarketPlaceService = game:GetService("MarketplaceService")

-----------------------------------------------------

-- Variables

local IDs = {
	[1272826368] = 3, -- +3 Inventory Slots
}

-----------------------------------------------------

-- Code

game.Players.PlayerAdded:Connect(function(player)
	MarketPlaceService.ProcessReceipt = function(purchaseInfo)
		local playerPurchased = game.Players:GetPlayerByUserId(purchaseInfo.PlayerId)
		if not playerPurchased then return Enum.ProductPurchaseDecision.NotProcessedYet end
		for productID, coinsGiven in pairs(IDs) do
			if purchaseInfo.ProductId == productID then
				playerPurchased.Gamepasses.InventorySlots.Value += coinsGiven
				return Enum.ProductPurchaseDecision.PurchaseGranted
			end
		end
	end
end)

Thanks!

You completely forgot to add the receipt info…

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
 
local productID = 0000000

local function promptPurchase()
	local player = Players.LocalPlayer
	MarketplaceService:PromptProductPurchase(player, productID)
end
1 Like

How is the function being called? The key value is being called there,

And you need the key there
Maybe it’s the issue?

2 Likes

did u put the player id
bz it happens sometimes

3 Likes

Nvm. I found the issue myself.

I did this :

PurchaseDeveloperProduct.MouseButton1Click:Connect(function()

instead of Button.MouseButton1Click:Connect(function())


Thanks all for helping!

1 Like