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

Code given to me doesn't work. Supposed to be title for current playing song. Pleas help?

Asked by 5 years ago
Edited 5 years ago

local sound = location-of-my-sound-piece local current = script.Parent.Sound

local songs = { [songId] = "songname", [songId2] = "songname2",
}

sound:GetPropertyChangedSignal("SoundId"):Connect(function() local name = songs[tonumber(sound.SoundId:match("%d+"))] if name then current.Text = name .. " is currently playing." end end)

This is a script that changes a GUI's text label to the currently playing song, it was given to me by a guy on the discord server, and he gave up after not explaining it at all since I'm just a curious annoyance and he doesn't care.

My issue is that the way this functions made no sense. It's using tonumber() but, the way my playlist works is it sets the soundid to ("http://www.roblox.com/asset/?id="..songid). But how would this work with tonumber()? Does it locate the number inside of the link and then :match it to the songname? If not can you please explain it to me and how to properly utilize it.

0
Uh, maybe present your own scripts Optikk 499 — 5y
0
Please make your own script, don't just take someone elses and ask for us to fix it. WideSteal321 773 — 5y
0
I'm not asking for a fix, I'm asking for an explanation, as I said, I don't know how the function works and I can't find anything about it. ISeeChase2 14 — 5y
0
Also it does make sense, the code matches the numbers out of the link. But yes, please give us your own script. ihatecars100 502 — 5y
0
So it automatically locates the numbers? ISeeChase2 14 — 5y

Answer this question