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.
- Add a ScreenGui in StarterGui.
- Put the SurfaceGui inside the ScreenGui.
- Go to the properties of SurafceGui and look for Adornee, and set the Adornee to the part.
- 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 
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 
1 Like