Alright, to start off, you didn't provide a lot of explanation and you also didn't specify what was on the parent but okay.
Let's assume that the parent is a text label and there are already songs on workspace.LobbyMusic
First you'll have to get the song table
Wich is workspace.LobbyMusic:GetChildren()
PS: I'm using workspace
instead of game.Workspace
since it's shorter
1 | local Music = workspace.LobbyMusic:GetChildren() |
Now we'll have to select wich song is playing
1 | for key,value in next ,Music do |
3 | if value.IsPlaying = = true then |
5 | script.Parent.Text = value.Name |
Now we'll detect whenever a song is playing
For this we'll use GetPropertyChangedSignal to detect whenever a song starts playing
By the way, this is the same code above but we'll add more code
01 | for key,value in next ,Music do |
03 | if value.IsPlaying = = true then |
05 | script.Parent.Text = value.Name |
09 | value:GetPropertyChangedSignal( "IsPlaying" ):Connect( function () |
11 | if value.IsPlaying = = true then |
13 | script.Parent.Text = value.Name |
And that's it!
If this answered your question mark it as the answer
Here is the final code if you want to copy it from here
01 | local Music = workspace.LobbyMusic:GetChildren() |
03 | for key,value in next ,Music do |
05 | if value.IsPlaying = = true then |
07 | script.Parent.Text = value.Name |
11 | value:GetPropertyChangedSignal( "IsPlaying" ):Connect( function () |
13 | if value.IsPlaying = = true then |
15 | script.Parent.Text = value.Name |