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

Get ID from rbxassetid:// ?

Hi. I am trying to get an integer from an rbxassetid://, but I need to figure out how do it. I tried this, but it doesn't work. I have no idea, would anybody help me out?

tonumber(string.sub(game.Workspace.Music.SoundId,string.len(game.Workspace.Music.SoundId)-(13)))

The script is supposed to get the last characters of a string (Counting the characters in the string and minus it by 13, the letters in rbxassetid.) and then using tonumber to make it an integer. But tonumber returns nil, which means the string contains also other characters rather than numbers... Any help?

1 answer

✓ Accepted answer
local ID = game.Workspace.Music.SoundId
ID = ID:sub(string.find(ID,"%d+"))
print(ID)

3 comments

0

Not working. The string still has the : and the //

0

I changed it, it works now.

0

Thanks! Now working. Even if I didn't understand what that sub does :P

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