I'm showing a Gui text songId from a song, But I'm trying to remove the rbxassetid:// and only the numbers, I wrote a code but it doesn't work, I've tried searching on google but nothing works, So may anyone help me?

My code:

		local allMusic = musicFolder:GetChildren()

		local randomMusic = allMusic[math.random(1,#allMusic)]
		local cloneMusic = randomMusic:Clone()

		cloneMusic.Parent = musicPlayer
		cloneMusic:Play()
		
		local songNameDefault = cloneMusic.SoundId:match("%d+")
		
		local songId = cloneMusic.SoundId
		local newStr, replaced = string.gsub(songId, "rbxassetid:// ", "")
		
		local songName = MarketPlaceService:GetProductInfo(songNameDefault,Enum.InfoType.Asset).Name
		
		print(songName.." has been selected as song")
		
		game:GetService("ReplicatedStorage"):FindFirstChild("UpdateNameGui"):FireAllClients(songName, newStr)

2 comments

0

Try removing space at

”rbxassetid:// “
0

Thanks, It works