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

how do I make a script do something when a surface gui has been clicked?

this is what I have and it doesn't work. no errors or anything. the script is a local script inside the text button in the surface gui that is in workspace.

local id = 11294323
local player = game.Players.LocalPlayer
local MS = game:GetService("MarketplaceService")


script.Parent.MouseButton1Click:connect(function(mouse)
	print("clicked")
	MS:PromptGamePassPurchase(player, id)
end)

2 comments

0

Make sure you have third party services enabled in studio, or else it won't work

0

do you mean third party purchases? because if so thats already enabled

1 answer

Localscripts dont run inside the workspace they only run in

A Player’s Backpack, such as a child of a Tool

A Player’s character model

A Player’s PlayerGui

A Player’s PlayerScripts.

The ReplicatedFirst service

see the API

2 comments

0

ah ok, how would I get the player to prompt the gamepass purchase then?

0

move the localscript to one of those locations (i suggest StarterPlayerScripts) btw you mark the answered as solved now

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