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

Unable to cast string to int64 GetProductInfo ?

Hello, I come asking you for help since not long ago I had created a script that allows me to update the name of the music and the id in a TextLabel.

Everything works perfectly, until Roblox Studio has them an update.

Since updating Roblox Studio, I have an error that shouldn't exist.

Since when I launch the game, it shows me the name of the product and its id, the problem is that the second music changes or that a user changes the music he makes me the error.

15:14:04.586 - Unable to cast string to int64 15:14:04.587 - Stack Begin 15:14:04.587 - Script 'Players.maxime66410.PlayerGui.MusicChange.Frame.TextLabel.LocalScript', Line 7 15:14:04.587 - Stack End

OR

15:14:01.863 - Unable to cast string to int64 15:14:01.864 - Stack Begin 15:14:01.864 - Script 'Workspace.Map.Deco.TV.TvMobileFirst.SongTitle.Script', Line 4 15:14:01.864 - Stack End

However before this update of roblox studio everything worked perfectly, no problem with int, nothing, I do not understand why he made me this error.

My Script :

while wait(1) do
	local id = game.Workspace:FindFirstChild("Music").SoundId
	local tring = string.sub(id,14)
	local nameOfMusic = game:GetService("MarketplaceService"):GetProductInfo(tring).Name
	script.Parent.SurfaceGui.Text.Text = nameOfMusic.." ( "..tring.." )"
	--print(tring)
end

1 answer

problem solved :

while wait(1) do
	local id = game.Workspace:FindFirstChild("Music").SoundId
	local tring = string.sub(id,14)
	local int = tonumber(tring)
	local nameOfMusic = game:GetService("MarketplaceService"):GetProductInfo(int).Name
	script.Parent.SurfaceGui.Text.Text = nameOfMusic.." ( "..tring.." )"
	--print(tring)
end

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