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

Dev Product Buttons Aren't Working?

Asked by 5 years ago

I'm developing a game where players can buy in-game cash for Robux. I used a model that has SurfaceGui buttons that are supposed to prompt the player to buy a dev product. However, in Studio and in-game pressing the button does not prompt anything.

Here is my code for one of the buttons:

local buyButton = script.Parent
local productId = 567187672 
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.MouseButton1Down:connect(function()
mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

mps.ProcessReceipt = function(info)
local plr = getPlayerById(info.PlayerId)
if plr and plr:FindFirstChild("leaderstats") and plr.leaderstats:FindFirstChild("Cash") then
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 1000
end
end
0
Forgot to mention there are no errors appearing in the output. Crvnberie 35 — 5y
0
Try putting print statements in various places especially when you click the button to see if it prints out something BennyBoiOriginal 293 — 5y

Answer this question