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

Unable to cast Instance to int64?

Asked by 5 years ago
Edited 5 years ago

The error is in line 49. ProductID is a NumberValue. I don't have any Idea on what to do now.

local ConfirmingPage = script.Parent.Parent.ConfirmingFrame
local AcceptedPage = script.Parent.Parent.PaymentAccepted
local DeclinedPage = script.Parent.Parent.PaymentDeclined
local PlaymentMod = script.Parent.Parent.PaymentMod
local ConfirmDialog = script.Parent.Parent.Parent
local PurchaseBackground = script.Parent.Parent.Parent.Parent.Flash
local TweenService = game:GetService("TweenService")
local ProductID = script.Parent.Parent.ProductID
local Material = script.Parent.Parent.Material
local NumOfMaterial = script.Parent.Parent.NumberOfMaterial

local Player = game:GetService("Players").LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")



-- Tweening

local TimeA = TweenInfo.new(1.25)

local GoalA = {}
GoalA.Position = UDim2.new(0.315, 0, 1.1, 0)

local TweenA = TweenService:Create(ConfirmDialog, TimeA, GoalA)
----------

local TimeB = TweenInfo.new(0.25)

local GoalB = {}
GoalB.BackgroundTransparency = 1

local TweenB = TweenService:Create(PurchaseBackground, TimeB, GoalB)


script.Parent.MouseButton1Click:Connect(function()
    ConfirmingPage.Visible = true
    wait(1.5)
    if Player.Name == "AswormeKarlito111" or Player.Name == "aowesomeLeoD12345" then
        ConfirmingPage.Visible = false
        PlaymentMod.Visible = true
        wait(1)
        local wayto = Player:WaitForChild("Database").Value_Inv:WaitForChild(Material.."_Value") 
        wayto = wayto + NumOfMaterial
        TweenA:Play()
        wait(1.25)
        TweenB:Play()
        PlaymentMod.Visible = false
    else
        MarketplaceService:PromptProductPurchase(Player, ProductID)
    end
end)



local onFinish

onFinish = function(player, passId, isPurchased)
    if passId == ProductID then -- check if id
        if isPurchased then -- if they purchased it, not click cancel
            wait(0.5)
            ConfirmingPage.Visible = false
            AcceptedPage.Visible = true
            wait(1)
            local wayto = Player:WaitForChild("Database").Value_Inv:WaitForChild(Material.."_Value") 
            wayto = wayto + NumOfMaterial
            TweenA:Play()
            wait(1.25)
            TweenB:Play()
            AcceptedPage.Visible = false
        else
            wait(0.5)
            ConfirmingPage.Visible = false
            DeclinedPage.Visible = true
            wait(1)
            TweenA:Play()
            wait(1.25)
            TweenB:Play()
            DeclinedPage.Visible = false
        end
    end
end

MarketplaceService.PromptProductPurchaseFinished:Connect(onFinish)
0
Is ProductID a value? If so change ProductID to script.Parent.Parent.ProductID.Value and try it again. Troxure 87 — 5y

1 answer

Log in to vote
2
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

The reason why this errors is because you're passing an Instance as an argument, when it's supposed to be an int64.

Instead, do this on line 49:

MarketplaceService:PromptProductPurchase(Player, ProductID.Value)
0
Thank you I always forgot that .Value thing when using Values ???? AswormeDorijan111 531 — 5y
0
Um those "????" were supposed to be emoji's. AswormeDorijan111 531 — 5y
0
But now on Line 64 when purchased I get an error too. Do you may know whats problem? AswormeDorijan111 531 — 5y
0
Oh nvm, again the same thing .Value AswormeDorijan111 531 — 5y
Ad

Answer this question