Unable to cast string to int64

Hello there,

I am trying to get the name from the sound ID of a sound instance which is placed in replicated storage.
My code is

while true do
	wait(2.5)
	script.Parent.Text = game:GetService("MarketplaceService"):GetProductInfo(game.ReplicatedStorage.MainSound.SoundId).Name
end

The error I am getting is
10:47:24.597 Unable to cast string to int64 - Client - LocalScript:3

I’ve tried to look on the devforums but I couldnt find anything that could help me directly.

Please correct me if I am doing something wrong.

well the name of the sound you referenced was “MainSound”. why would you want to go into the sound id and pull a name out (which you can’t because it’s a number) when you can just use


script.Parent.Text = game:GetService("MarketplaceService"):GetProductInfo(game.ReplicatedStorage.MainSound.Name

sorry if this isn’t what you’re looking for but another way would be to attach a stringvalue to the sound and change the value of the stringvalue

Alr, I’ll lyk after I try this out.

Its now telling me that an argument is missing.

The SoundId property is a string, as shown here.
image

That’s what’s causing the error, GetProductInfo requires an int64 (or, more specifically, a plain number). You can try to remove the rbxassetid:// part of the string, then turn it into a number using tonumber.

local snd = game.ReplicatedStorage.MainSound.SoundId

local proc = string.gsub(snd, "rbxassetid://", "")

local num = tonumber(proc)

Then use the num value to get the ID.