Buy gamepass via surfaceGUI?

Right so, I made this part with a surfaceGUI on it, and the button that says “50R$ - BUY”, has a local script inside, which wont work for some reason.
The said part:
image
The explorer view:
image
The LocalScript inside of the TextButton

local GamepassID = 136732149 -- the gamepass ID im trying to use

script.Parent.MouseButton1Click:Connect(function()
	game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, GamepassID)
end)

It works for other people, ive tried with normal ScreenGUIs too, and its not working in studio or in-game. Even though I already own the gamepass, it should still come up with a prompt saying that I already own it?

Any help is appreciated, thanks.

3 Likes

It’s because it is a localscript.

You cannot have localscripts in workspace, make it a normal script

2 Likes

Place the SurfaceGUI into StarterGUI and set the Adornee property of the SurfaceGUI to the Donation part.

2 Likes

There are multiple ways of addressing this problem. Here are two solutions:

  1. Use Logan’s method. Move the SurfaceGui into StarterGui and set its Adornee to the part.

Or,

  1. Copy the contents of the script then delete it. Then, create a regular script and set its RunContext property to Client. Then, paste the code back in.
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.