Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Prompt purchase doesn't work?

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)

1 comment

0

Local Script or Server Script? And where you put that?

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.