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

Why does this surface gui script not work?

Asked by 9 years ago
local buyButton = script.Parent
local productId = 19201593
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("leaderstats") and plr.leaderstats:FindFirstChild("Credits") then
plr.leaderstats.Points.Value = plr.leaderstats.Credits.Value + 100000 
end
end

For some reason, when I click it it does not work.

1 answer

Log in to vote
0
Answered by
iSvenDerp 233 Moderation Voter
9 years ago

Hi. Im on mobile so I cant test what im going to show you. I believe u just simply need to add the connection. Youll need to put a click detector not in the script but in the scripts parents. So...

buyButton.ClickDetector.MouseClick:connect(Clicked) --This is the connection that calls that your clicking something. Put this after the 2 ends on a new line.

Hope this helped let me know if it did like i said I cant test it so not positive it works but im almost positive:)

Ad

Answer this question