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!