Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

developer product gives more than once credit when purchased?

Asked by 5 years ago

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
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. User#19524 175 — 5y
0
so how should i use remote events to do it? Creeper_Dude158 11 — 5y
0
well studio just 'crashed' and rip all my stuff from past 2 hours Creeper_Dude158 11 — 5y
0
Studio Autosaves! hipenguinflip 30 — 5y

Answer this question