Surface GUI Interaction

Hello, I am trying to make a Surface GUI to the replace Screen GUI for uncluttering the screen but how do I trigger a Dev Product Purchasement from a Button on the Surface GUI?

You can still use MouseButton1Click on buttons under surface guis.

local MarketplaceService = game:GetService"MarketplaceService"
local Players = game:GetService"Players"
local LocalPlayer = Players.LocalPlayer
--change to how you set up your game
workspace.Part.SurfaceGui.TextButton.MouseButton1Click:Connect(function()
    MarketplaceService:PromptProductPurchase(LocalPlayer,--[[fill in your own product id]])
end)

Surfaces Gui’s must be parented to StarterGui in order to work correctly. To put the Gui onto whatever BasePart you desire simply set the Adornee value

1 Like

How do I parent the Surface GUI with StarterGUI?

Surface guis under a part have always worked fine for me, what makes them only work under startergui?

Mmm, that does not seem to work, I have tried it but no luck

Are you getting any errors? Something like that worked fine for me.

No errors were picked up, thats weird

Make sure you’re using a local script while accessing the Surface Gui

localscript


local Player = game.Players.LocalPlayer
local MPS = game:GetService("MarketplaceService")
local SurfacePart = workspace:WaitForChild("SurfaceBlock")
local SurfaceGui = SurfacePart.SurfaceGui
local Button = SurfaceGui.TextButton

local ID = 00000
Button.Activated:Connect(function()
	MPS:PromptProductPurchase(game.Players.LocalPlayer, ID)
end)

SurfaceGuiButton.rbxl (18.2 KB)

though it’s better use a remote event and do the prompting on the server

3 Likes

That does not work either, has the feature been deprecated or what am i doing wrong?

I just tested it, it works

where are you putting the local script, it has to be a descendant of the player or of the player’s character

1 Like

I am putting the local script inside the TextButton


the local script has to be in on of those places ^

you can open the place a sent to see an example

3 Likes

Oh my gosh, I did not look into the StarterPlayerScripts Folder and it worked, thank you all for the help, it means alot :smiley:

1 Like

Huh must of changed, this was true in past.