Purchase going through in studio but not in-game

For some reason when I purchase a developer product the money is given to me in studio, but when I purchase it in-game it doesn’t give the money

Serverside:

local function processReceipt(receiptInfo)
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	if purchaseHistory[receiptInfo.PurchaseId] then
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end

	local productId = receiptInfo.ProductId
	local productInfo = ProductDefinitions[productId]

	if productInfo then
		CurrencyManager.AddMoney(player, productInfo.Reward)
		purchaseHistory[receiptInfo.PurchaseId] = true
		
		local data = DataStoreManager.GetPlayerData(player)
		AnalyticsService:LogEconomyEvent(
			player,
			Enum.AnalyticsEconomyFlowType.Source,
			"Money",
			productInfo.Reward,
			data.Money + productInfo.Reward,
			Enum.AnalyticsEconomyTransactionType.IAP.Name,
			productInfo.Name
		)
		MoneyPurchaseEvent:FireClient(player, productInfo.Reward)
		
		return Enum.ProductPurchaseDecision.PurchaseGranted
	else
		NotificationManager.SendNotification(player, "Purschase Failed. Please Try Again.")
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
end

MarketplaceService.ProcessReceipt = processReceipt

Clientside:

local function setupButtons()
	for buttonName, productInfo in pairs(productButtons) do
		local productType = productInfo.Type
		local productId = productInfo.Id
		local button = purchasableMoneyFrame:FindFirstChild(buttonName)
		if button and button:IsA("ImageButton") then
			local amountLabel = button:FindFirstChild("Amount")
			if amountLabel and amountLabel:IsA("TextLabel") then
				local productInfo = ProductDefinitions[productId]
				if productInfo then
					amountLabel.Text = "+" .. tostring(productInfo.Reward)
				else
					amountLabel.Text = "Product Not Found"
				end
			end
			
			button.MouseButton1Click:Connect(function()
				print(`Purchase button click. player: {player}, productId: {productId}`)
				if productType == "GamePass" then
					print(`PromptGamePassPurchase. player: {player}, productId: {productId}`)
					MarketplaceService:PromptGamePassPurchase(player, productId) -- This
				else
					print(`PromptProductPurchase. player: {player}, productId: {productId}`)
					MarketplaceService:PromptProductPurchase(player, productId) -- This
				end
			end)
		else
			warn(buttonName .. " Wasn't found or is not an Imagelabel.")
		end
	end
end

Heres the output: Players.< Player >.PlayerGui.UserInterface.PurchasableMoney.PurchasableClient:61: do not run what you just ran (vulnerable function).

1 Like

“Heres the output: Players…PlayerGui.UserInterface.PurchasableMoney.PurchasableClient:61: do not run what you just ran (vulnerable function).”

Never seen this error and can’t see how you even ran into this… Unless this is being used as a
Client (local) script. Make it a Server script and fire a remote to trigger it.

It’s a serverside script in serverscriptservice, not sure how it happened as well.

Something happening on the client is causing this error is my guess.

local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
--
MarketplaceService:PromptGamePassPurchase(localPlayer, productId)
MarketplaceService:PromptProductPurchase(localPlayer, productId)

Just gives an error without the player in there

This is all you need to buy a gamepass.

--ClientScript
local gamepassID = ????? --passID
local player = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
	mps:PromptGamePassPurchase(player, gamepassID)
end)