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

Unable to cast Instance to int64?

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)

1 comment

0

Is ProductID a value? If so change ProductID to script.Parent.Parent.ProductID.Value and try it again.

1 answer

✓ Accepted answer

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)

4 comments

0

Thank you I always forgot that .Value thing when using Values ????

0

Um those "????" were supposed to be emoji's.

0

But now on Line 64 when purchased I get an error too. Do you may know whats problem?

0

Oh nvm, again the same thing .Value

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