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

Can you remove a section from a string?

Asked by
MattVSNNL 620 Moderation Voter
3 years ago

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)
0
Try removing space at ~~~~~~~~~~~~~~~~~ ”rbxassetid:// “ ~~~~~~~~~~~~~~~~~ WINDOWS10XPRO 438 — 3y
0
Thanks, It works MattVSNNL 620 — 3y

Answer this question