The Button Does Not Disappear

I want that if the player has the gamepass it makes the gamepass button disappear.

Here is my script.
Local Script:

local Player = game.Players.LocalPlayer
local Button = script.Parent
local MarketPlaceService = game:GetService("MarketplaceService")
local PassId = --Nevermindthis--

if MarketPlaceService:UserOwnsGamePassAsync(Player,PassId) then
	Button.Visible = false
end

Button.MouseButton1Click:Connect(function()
	MarketPlaceService:PromptGamePassPurchase(Player, PassId)
end)

UserOwnsGamepassAsync expects a UserId, not a player instance, use Player.UserId

Well I just tried without thinking of that ill try now

Try this maybe?, Because your checking if the player owns the Gamepass when they join (The script starts running) but not when they click the button.


Button.MouseButton1Click:Connect(function()
	MarketPlaceService:PromptGamePassPurchase(Player, PassId)
   if MarketPlaceService:UserOwnsGamePassAsync(Player,PassId) then
	Button.Visible = false
   end
end)

Just checked the Dev Hub and seems to be a player instance not a UserId

Did you check the right article?

I want to check exactly when the join. That’s the point.

Yes i did check the right article but i guess i overlooked that.

think i did

Use PlayerAdded then do Player.UserId.

When did I refer to PromptGamePassPurchase? My original post was referring to UserOwnsGamePassAsync

PlayerAdded doesn’t work in Localscripts

Can’t he just use LocalPlayer then?

My bad, Roblox not being consistent again!

1 Like

It works when I add the UserId

He already is using LocalPlayer already

I did use LocalPlayer what do you mean?