Why does this Gam ePass thing Not Working?

Is your part a child of a model? Share a screenshot of the entire explorer window.

local players = game:GetService("Players")
local player = players.LocalPlayer
local marketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 22612992

game.Workspace.GamePassPart.SurfaceGui.ImageButton.MouseButton1Click:Connect(function()
	marketPlaceService:PromptGamePassPurchase(player, gamePassId) 
end)

This code will work.

3 Likes

So, here’s what you need to know.

SurfaceGui buttons won’t work unless you do some stuff. Here are the steps.

  1. Add a ScreenGui in StarterGui.
  2. Put the SurfaceGui inside the ScreenGui.
  3. Go to the properties of SurafceGui and look for Adornee, and set the Adornee to the part.
  4. Now just add a local script inside the ImageButton and type this
local player = game.Players.LocalPlayer
local marketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 22612992

script.Parent.MouseButton1Click:Connect(function()
	marketPlaceService:PromptGamePassPurchase(player, gamePassId) 
end)

Edit: ig nvm lol

1 Like

finally, the script in starter player scripts worked :slight_smile:

and lol no scripts in my workspace is working

Congrats, local scripts will only work when they are placed in the correct locations.

A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • 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
2 Likes

Never really knew that, thanks for letting me know!

me too but when i worked on other games, there they seemed to be working :confused:

1 Like