Can only register ProcessReceipt callback on server

local MS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ProductID = 1140043568
local PlayerLocal = game.Players.LocalPlayer

local function processPurchase(receiptInfo)
	local Player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if Player then
		PlayerLocal.leaderstats.Rank.Value = "Lol You Purchased this"
		print("Player Bought a Rank")
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
wait(3)
MS:PromptProductPurchase(PlayerLocal, ProductID)
MS.ProcessReceipt = processPurchase

3 comments

1

on line 19 you are setting ProcessReceipt callback to processPurchase on the client, you need to do it on the server, that's what the error says.

0

So the Solution is To Put Line 19 with assigned variables to an server script?