"unable to cast string to int64" shows up when I try to buy a shirt through a script

  1. What do you want to achieve? I’am trying to figure out a solution to this problem

  2. What is the issue? Whenever I try to buy a shirt through a script it gives me this error:error

  3. What solutions have you tried so far? I’ve tried to look through the script for any issues but I couldn’t find anything

local RE = script.Parent:WaitForChild("RemoteEvent")

local US = game:GetService("UserInputService")

local marketplace = game:GetService("MarketplaceService")
local ID = script.Parent.Parent.Parent.Adornee.Parent.Rig.Shirt.ShirtTemplate

script.Parent.MouseButton1Click:Connect(function()
	marketplace:PromptPurchase(game.Players.LocalPlayer, script.Parent.Parent.Parent.Adornee.Parent.Rig.Shirt.ShirtTemplate)
end)

I’am using a billboard GUI for the button, that’s why I use adornee

ShirtTemplate is a content url to a shirt while MarketplaceService:PromptPurchase needs a number id to the shirt. You can use string.match to get it.

So replace

script.Parent.Parent.Parent.Adornee.Parent.Rig.Shirt.ShirtTemplate

with

string.match(script.Parent.Parent.Parent.Adornee.Parent.Rig.Shirt.ShirtTemplate, "%d+")

Thankyou, I only have one problem though, what do you mean by %d+?

Oh my bad, I meant "%d+" which when used in a string pattern, it will return a matched whole number.