GetProductInfo "Argument 1 missing or nil"

Hello Everyone This is my first post! Anyways, Im trying to Get product info when a player types in an id for a song, but the problem is that I am getting a “Argument 1 missing or nil” error from the output when it tries to get product info

Here is my script (a local script in a guibutton)

local RS = game:GetService("ReplicatedStorage")
local MS = game:GetService("MarketplaceService")
local idbox = script.Parent.Parent.id
local texttonumber = tonumber(idbox.Text)

script.Parent.MouseButton1Click:Connect(function()
	if idbox.Text == nil then
		print("no id inputted")
	else
		local song = MS:GetProductInfo(texttonumber)
		if song.AssetTypeId == 3 then
			print("is a song")
		else
			print("not a song")
		end
	end
end)

(I have already looked through other posts but none of them answered my question)

I Thank you for your time! :grinning:

I believe you’re saving the texttonumber variable outside the MouseButton1Click Event, so by default it’ll resort to the Empty TextButton when you click “Submit”

Try putting it inside and see if that works

local RS = game:GetService("ReplicatedStorage")
local MS = game:GetService("MarketplaceService")
local idbox = script.Parent.Parent.id

script.Parent.MouseButton1Click:Connect(function()
    local texttonumber = tonumber(idbox.Text)

	if idbox.Text == nil then
		print("no id inputted")
	else
		local song = MS:GetProductInfo(texttonumber)
		if song.AssetTypeId == 3 then
			print("is a song")
		else
			print("not a song")
		end
	end
end)

Oh, That worked! Thanks for the help