Gamepass Gui Button Won't Work

Ok so I’ve been working on this for 3-4 hours, trying various methods for using MarketplaceService:UserOwnsGamePassAsync(UserID, GamePass ID) and I just can’t figure it out.

This is my current Local Script

local Id = 4933128 --New Gamepass ID (Not old type)

game.Players.PlayerAdded:Connect(function(Player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, Id) then
	    script.Parent.ia.Visible = true 
    end
end)

After running no outputs are given (Not even the [id] isn’t a GamePass use PlayerOwnsAsset instead)

I’ve watched video after video, read instructions after instructions, and nothing has worked so far. However I did have another gamepass Script (Not Local) and it worked just fine. The code instead would give you a tool. I tried copying off that script, but no luck. Any Help at all is appreciated. Thank you!

1 Like

You’re checking for gamepass every time a new player joins. Since you’re running it in a local script, that means your player has already joined, and thus PlayerAdded won’t fire again in solo test.

Instead of using the event, you should check for gamepass right away:

local Id = 4933128 --New Gamepass ID (Not old type)

local Player = game.Players.LocalPlayer --Our player

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, Id) then
	script.Parent.ia.Visible = true 
end
2 Likes

Thank you! This was the one thing I didn’t try. You are very much a help to me.