i have this developer product that allows players to buy 1 skip, but when players buy more than 1 it gives them more than once credit, when it shoud only give them one every time. why?

local buyButton = script.Parent
local productId = 374138275 --change to dev product id
local mps = game:GetService("MarketplaceService")

function getPlayerById(id)
for i,v in pairs(game.Players:GetPlayers()) do
if v.userId == id then
return v
		end
	end
end

buyButton.MouseButton1Click:connect(function()
mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

mps.ProcessReceipt = function(info)
local plr = getPlayerById(info.PlayerId)
if plr and plr:FindFirstChild("NumberOfSkips")  then
plr.NumberOfSkips.Value = plr.NumberOfSkips.Value + 1
print(plr.NumberOfSkips.Value)
	end
end

4 comments

0

ProcessReceipt is a server-sided callback, it cannot be used on the client. You may want to use remotes. And connect and userId are deprecated, use Connect and UserId. And pleeeease indent your code as well.

0

so how should i use remote events to do it?

0

well studio just 'crashed' and rip all my stuff from past 2 hours

0

Studio Autosaves!