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

Cannot cast instance to int64 with gamepass? [SOLVED]

Asked by 4 years ago
Edited 4 years ago

This question has been solved by the original poster.

Alright so, recently I decided I would include a gamepass in one of my games. The issue is that, I cannot seem to figure out this (what should be working) code/bug. I have tried to change it up, changing the gamepassid variable into an int, into a string. I have tried transforming it using tonumber() and tostring() to no avail. The current status is that there is a intvalue as a child under the script object. Here is my code:

local market = game:GetService("MarketplaceService")

local function touched(part)
    if part.Parent:FindFirstChild("Humanoid") then
        if market:UserOwnsGamePassAsync(game.Players:GetPlayerFromCharacter(part.Parent), script.gamePass_ID.Value) then
            if part.Parent:FindFIrstChild("alreadyTouched") then
                return nil
            end
            part.Parent.Humanoid.MaxHealth = part.Parent.Humanoid.MaxHealth + 500
            part.Parent.Shirt.ShirtTemplate = "https://www.roblox.com/catalog/1238057537"
            part.Parent.Pants.PantsTemplate = "https://www.roblox.com/catalog/1350584307"
            local alreadyTouched = Instance.new("BoolValue", part.Parent)
            alreadyTouched.Name = "alreadyTouched"
        else
            market:PromptGamePassPurchase(game.Players:GetPlayerFromCharacter(part.Parent), script.gamePass_ID.Value)
        end
    end
end

script.Parent.Touched:Connect(touched)

I've verified that the gamepass ID is correct.

The error I should mention is: "Cannot cast instance to int64".

EDIT: Turns out that I gave the function "UserOwnsGamePassAsync()" the player model instead of the UserId, apologies for my idioticness.

Answer this question