I've got a simple script that when it is clicked it will prompt a product purchase. Here is a sample code for a R$10 purchase.
productId = 33054891 script.Parent.ClickDetector.MouseClick:connect(function(plr) game:GetService("MarketplaceService"):PromptProductPurchase(plr, productId) end) script.Parent.ClickDetector.MouseHoverEnter:connect(function() script.Parent.SurfaceGui.Ammount.TextTransparency = 0.5 script.Parent.SurfaceGui.Sign.TextTransparency = 0.5 script.Parent.Enter.TextLabel.Visible = true end) script.Parent.ClickDetector.MouseHoverLeave:connect(function() script.Parent.SurfaceGui.Ammount.TextTransparency = 0 script.Parent.SurfaceGui.Sign.TextTransparency = 0 script.Parent.Enter.TextLabel.Visible = false end)
Thank you in advance.
Your main problem here is either that plr is not defined, or your code is in a server script when it really should be local.
Move all your code into a LocalScript, and define the variable plr (probably as game.Players.LocalPlayer)
If you need the LocalScript to change a value on the server, use a RemoteEvent.