I am making a basic SurfaceGui which has ImageButtons on it to purchase in game Points. Sadly, the code doesn’t appear to be working and I can’t see why…
Here is the code in the ImageButton:
MPS = game:GetService("MarketplaceService")
id = 974436122
local player = game.Players.LocalPlayer
function ButtonClicked()
MPS:PromptProductPurchase(player, id)
end
script.Parent.Activated:Connect(ButtonClicked)
Here is the code in PurchaseHandler (located in Server Script Service):
MPS = game:GetService("MarketplaceService")
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 974436122 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
local points = player.leaderstats.Points
points.Value = points.Value + 50
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
the id for the product you prompt (id = 974436122) is different from the id you check in the ProcessReceipt callback (if receiptInfo.ProductId == 974435598 then)
Oh im sorry its because the store has different purchases and i just took the first ones that came. Its been fixed now, but thats not the problem. Somehow I can’t click on the buttons.
that is not the problem, MPS would still be the MarketplaceService even if it isnt a local var
for MouseButton1Click, it dont matter, Activated works just as well, and it is even recommended because MouseButton1Click is a misleading name, it detect input from mobile touch even tho it is named MouseButton1Click
@MrDaBigBoss but changing to MouseButton1Click could fix it because of this bug where if your button is in a scrolling frame, when its Zindex property is lower than ScrollingFrame’s Zindex, Activated will not work. if you want to use Activated, make the button Zindex higher than ScrollingFrame Zindex