Hello! I was writing script which puts in text label current sound’s name. But wheck I laugh test game, output says there is an error. This is script I wrote:
local sound = game.Workspace.Sound
local SoundId = tonumber(sound.SoundId)
local Asset = game:GetService("MarketplaceService"):GetProductInfo(SoundId)
while wait() do
script.Parent.Text = Asset.Name
end
The issue is you are doing tonumber() on a string that contains more than just numbers. If you want to get just the numbers you have to use Pattern Matching. Below is the post that solves this issue and this Developer Hub article that goes over strings explains how tonumber() works.
local Sound = game.Workspace.Sound
local SoundId = Sound.SoundId:match("%d+")
local Asset = game:GetService("MarketplaceService"):GetProductInfo(SoundId)
while wait() do
script.Parent.Text = Asset.Name
end
Just like what @xZylter said, you have to use pattern matching to get just the numbers and thats what I did or alternatively, you don’t have to do what I said but instead you can change tonumber(sound.SoundId) to tonumber([The ID of the sound, only numbers])