Prompt Purchase does not work

Hey there,
i need help.
Im making an gamepass purchase for my Billboard, but when i click the button nothing shows up. I get no errors.
These are the locations:
ss

And this is my code:

local marketplace = game:GetService("MarketplaceService")
local gamepassID = 63421396

local plr = game.Players.LocalPlayer

local button = script.Parent

button.MouseButton1Click:Connect(function()

	local hasPass = marketplace:UserOwnsGamePassAsync(plr.UserId, gamepassID)	
	if hasPass then		
		print("the user owns the gamepass")
	else
		marketplace:PromptGamePassPurchase(plr,gamepassID)		
	end	
end)

Also its a local script u can see it there.
Could someone help? If yes thank you!

Goodbye!

Where is it run? since local scripts doesnt run in workspace for example.

game.Workspace.(model).(part).(billboardGUI).Frame.(the button)

change it to a normal script, local scripts don’t run in workspace

instead of the player variable, put player in the parameters of the click function

local marketplace = game:GetService("MarketplaceService")
local gamepassID = 63421396

local button = script.Parent

button.MouseButton1Click:Connect(function(plr)

	local hasPass = marketplace:UserOwnsGamePassAsync(plr.UserId, gamepassID)	
	if hasPass then		
		print("the user owns the gamepass")
	else
		marketplace:PromptGamePassPurchase(plr,gamepassID)		
	end	
end)

ahhh thats the problem. Since its in workspace Local Script doesnt work.

i get this error.

U maybe forgot:
game.Players.PlayerAdded:Connect(function(plr)

no, you don’t need that if you create the player variable in the mouse click function parameters. try it anyway and remove the plr from the parameters

Let me test it, maybe it works idk

You may have a problem. Since the gamepass only loads if you have clicked the button if you have not done anything in other script for that

I just tried it with my playeradded function and i get this:

It really works, but u forgot the playeradded function but now i have it thank you

Also, i have made else, so if i dont own the gamepass its propmt purchasing, so i shouldve deleted it from my inventory so it works but i have it thanks

Does it give you effect or whatever you have as reward if you join to the game?

No, but im trying to do an Prompt purchase finished thingy

Try this to load effect after joining:

local marketplace = game:GetService("MarketplaceService")
local gamepassID = 63421396


game.Players.PlayerAdded:Connect(function(plr)

	local hasPass = marketplace:UserOwnsGamePassAsync(plr.UserId, gamepassID)	
	if hasPass then		
		--put effect here
	
	end	
end)

put in serverscriptservice