Script:
local MarketplaceService = game:GetService("MarketplaceService") local ProductID = 16498748 local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() MarketplaceService:PromptGamePassPurchase(player, ProductID) end)
I wouldn't recommend using a local script in the server. You should use a RemoteEvent to communicate from the server to client.
Server Script:
local Event = game.ReplicatedStorage.Event --RemoteEvent in ReplicatedStorage local ClickDetector = game.Workspace.Part.ClickDetector --ClickDetector ClickDetector.MouseClick:Connect(function(p) --Since TextButtons dont return any information about who interacted with it, we can use a click detector Event:FireClient(p) --Fire the RemoteEvent end)
Local Script:
local MarketplaceService = game:GetService("MarketplaceService") local ProductID = 16498748 local Event = game.ReplicatedStorage.Event --RemoteEvent in ReplicatedStorage local Player = game.Players.LocalPlayer Event.OnClientEvent:Connect(function() MarketplaceService:PromptGamePassPurchase(Player, ProductID) end)
Both scripts were fully-tested. No errors or bugs were found.
This problem happened to me before, you can try to put the script in StarterPlayersScript instead of TextButton.
In:
game.Workspace.ThePart.SurfaceGUI.TextButton
Add a Click Detector. This may help