Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Check if player owns Gamepass dont work?

Why is this dont working the Error is

Unable to cast Instance to int64

Here is my Script:

local id = 6743521
 
game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player, id) then 
        print(player.Name .. " has the game pass!")
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

I hope somebody can help me :D

1 answer

✓ Accepted answer
local id = 6743521

game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then 
        print(player.Name .. " has the game pass!")
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

The problem was that you tried to do (player, id) instead of (player.UserId, id)

If you look in the wiki, the arguments to the function are 2 int64, respectively UserId and GamepassId.

1 comment

1

Thanks :D

This discussion is preserved as it was. New answers, comments, and votes are closed.