Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Instance not cast to int64 error in purchase handler?

Asked by 4 years ago

Hello, im trying to make a purchase manager and everything works fine in it BESIDE the gamepasses when checking if UseOwnsGamePassAsync i get Instance not cast to int64 error help need thanks!

v.Head.Touched:connect(function(hit)
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            if v.Head.CanCollide == true then
                if player ~= nil then
                    if script.Parent.Owner.Value == player then
                        if hit.Parent:FindFirstChild("Humanoid") then
                            if hit.Parent.Humanoid.Health > 0 then
                                local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
                                if PlayerStats ~= nil then
                                    if (v:FindFirstChild('Gamepass')) and (v.Gamepass.Value >= 1) then
                                        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player,v.Gamepass.Value) then
                                            Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
                                        else
                                            game:GetService ("MarketplaceService"):PromptGamePassPurchase(player,v.Gamepass.Value)
                                        end

V is just a value that is open for whenever its needed

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
4 years ago

Check the documentation for UserOwnsGamePassAsync.

The first argument is a user id, not a Player instance.

:UserOwnsGamePassAsync(player.UserId, v.GamePass.Value)
0
Thanks for the quick answer ill try it out DecaSide 0 — 4y
0
I get the error attempt to index field 'UserId' (a number value) DecaSide 0 — 4y
Ad

Answer this question