local SoundId = game.Workspace.MusicPlayer.MusicScript.Sound.SoundId local Asset = game:GetService("MarketplaceService"):GetProductInfo(SoundId) while true do script.Parent.Text = "Music name ="..Asset.Name.."/ ID ="..SoundId.."" wait(5) end
Output---------------------------
13:50:18.076 - Unable to cast string to int
13:50:18.077 - Stack Begin
13:50:18.078 - Script 'Players.Sphynks.PlayerGui.MUsci.TextLabel.LocalScript', Line 2
13:50:18.079 - Stack End
Hey Sphynks,
rbxassetId://[ID]
local id = "rbxassetid://787837201"; local real_id = id:match("%d+") -- Returns the numbers in the string. print(real_id) -- Prints the id itself.
local gui = script.Parent; local music = workspace.MusicPlayer.MusicScript.Sound; local SoundId = music.SoundId local real_id = SoundId:match("%d+") local Asset = game:GetService("MarketplaceService"):GetProductInfo(real_id) while wait() do gui.Text = "Music name ="..Asset.Name.."/ ID ="..SoundId end
~~ KingLoneCat
Trying to help , check it.
Original Explained:
local SoundId = "rbxassetid://787837201" -- You are trying to find an assetId ,not a string. local Asset = game:GetService("MarketplaceService"):GetProductInfo(rbxassetid://787837201)--This is NOT an assetId. local Asset1 = game:GetService("MarketplaceService"):GetProducInfo(78737201) -- This is a proper assetId. while true do script.Parent.Text = "Music name ="..Asset.Name.."/ ID = SoundId " wait(5) end
The above is a wrong interpretation of string to Integer.
Corrected one:
local SoundId = "rbxassetid://787837201" -- You are trying to find an assetId not a string. local real_id = SoundId:match("%d+") -- Matching a pattern. print(real_id) -- Check output to confirm the Id is the right one. local Asset = game:GetService("MarketplaceService"):GetProductInfo(real_id)--This gets the real soundId while true do script.Parent.Text = "Music name ="..Asset.Name.."/ ID = SoundId " wait(5) end
Thank you for reading.
I am still learning RbxLua.