I have a part, if you touch it and own the gamepass, you will get moved to a location. If you don't own it, you will be prompted the gamepass "buy screen". But I get this error:
Unable to cast Instance to int64
This is the script:
GamePassService = game:GetService('MarketplaceService') toolGamePass = 2068240 script.Parent.Touched:Connect(function(hit) player = game.Players:GetPlayerFromCharacter(hit.Parent) if GamePassService:UserOwnsGamePassAsync(player,toolGamePass) then hit.Parent:MoveTo(Vector3.new(0,100,0)) else GamePassService:PromptGamePassPurchase(player.PlayerId, toolGamePass) end end)
UserOwnsGamePassAsync needs a userId, but you passed an instance which gave you this error.
Fixed line:
if GamePassService:UserOwnsGamePassAsync(player.UserId, toolGamePass) then
PlayerId isn't a valid property of the player, unless you created it yourself, but, use player.UserId