Why does this Gam ePass thing Not Working?

use (player, gamePassId) instead of (player.UserId, gamePassId). (replied to the wrong person sorry)

still there are problems!.

The script i not running

Finally I am telling, “The Script is Not Running” even for a print statement!

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 works for me in Studio. Make sure the script is in the StarterPlayerScripts folder and rename the part to “GamePassPart” make sure it is parented to the workspace.

HELLO
I SAID
if its not the players character then a locAL script will not run

idk why these errors are coming:

these are default roblox scripts :confused:

I know, I forgot to hit shift.

it could be that your in team create and have a slow internet

EDIT:after a second thought im thinking that the gamepass server handler script might be the problem

Those are likely from free models, check the last code block I provided, it worked for me.

can u explain to me in detail? a little bit more??

what?? u mean i m using free models?? i m using a normal part lol

hey try this

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

local gamePassId = 22612992


workspace.Part.SurfaceGui.ImageButton.MouseButton1Click:Connect(function()
	marketPlaceService:PromptGamePassPurchase(player,gamePassId) 
end)

First of, add a print to see if the clicking is actually working or not.

This is just a copy and paste of what I provided above.

yes i m telling that to thse people for long time, the code is not running, i mean the script

workspace is not A Player’s character model

I mean those errors are unrelated to the part itself. They are related to the models named “Ragdoll” and “Car”.

bruh… we already tryed with other things, that script is not even running :confused:

i just got an idea… what you can do is put the surface gui and the script in the StarterGui then put the Adornee property of the surface gui to the part that you want the gui to show up