Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to get the name of a song from id?

Asked by
Kblow1 53
6 years ago

Any ideas to why this doesnt work?

local id = game.Workspace.Sound.SoundId
currentsong = game:GetService("MarketplaceService"):GetProductInfo(id).Name
print(currentsong)

"unable to cast string to int64"

1 answer

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

The problem is that Roblox can't convert your string to a number, because your sound ID is probably like "rbxassetid://"

You could use string.match() with the %d+ string pattern, get the substring, store the ID number in a script, or do something else.

1
tonumber( id:match("%d+$") ) cabbler 1942 — 6y
0
nice one cabbler DeceptiveCaster 3761 — 6y
Ad

Answer this question