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

Prompt purchase doesn't work?

Asked by 5 years ago

Hi, i made a sort of purchase prompting surfacegui but it doesn't seem to be working for me. any help>

local plr = game.Players.LocalPlayer
local gpID = 4692614

script.Parent.MouseButton1Click:Connect(function()
    game:GetService("MarketplaceService"):PromptGamePassPurchase(plr, gpID)
end)
0
Local Script or Server Script? And where you put that? valchip 789 — 5y

1 answer

Log in to vote
0
Answered by
Sir_Melio 221 Moderation Voter
5 years ago
Edited 5 years ago

It seems like you're using a LocalScript, which does not work in the Workspace (except in the local player's character model).

You should instead handle the click event from a valid place, like the StarterPlayerScripts (later inserted into the PlayerScripts folder inside the player). Try navigating to the part that has the SurfaceGui, f.e.:

local plr = game.Players.LocalPlayer
local gpID = 4692614

workspace.Part.SurfaceGui.Button.MouseButton1Click:Connect(function()
    game:GetService("MarketplaceService"):PromptGamePassPurchase(plr, gpID)
end)
Ad

Answer this question