Current Song TextLabel Script not working?

Many games have a text label that tells you what song is playing. I tried to make one, but it is not working. Here is script:

local SoundId = game.Players.LocalPlayer.PlayerScripts.LocalBackgroundMusic.BGM.SoundId
local Asset = game:GetService("MarketplaceService"):GetProductInfo(SoundId)
script.Parent.Text = ("Current Song: "..Asset.Name)

Help would be appriciated!

You need to pass in the sound id only and second argument should be 0.

Like this,

local Asset = game:GetService("MarketplaceService"):GetProductInfo(111111111,0)
1 Like

what if its a playlist of sounds?

Well, then define all of the assets

1 Like

dis da script now (it still does not work)

local Song = game.Players.LocalPlayer.PlayerScripts.LocalBackgroundMusic.BGM

while true do
if Song.SoundId == "rbxassetid://1587473857" then
	script.Parent.Text = ("Current Song: Chill")
end

if Song.SoundId == "rbxassetid://366682733" then
	script.Parent.Text = ("Current Song: Chill2")
end

if Song.SoundId == "rbxassetid://911100428" then
	script.Parent.Text = ("Current Song: idealism lonely")
end

if Song.SoundId == "rbxassetid://2240495212" then
	script.Parent.Text = ("kudasai - attached")
end

if Song.SoundId == "rbxassetid://2663497976" then
	script.Parent.Text = ("kudasai - sapphire")
end

if Song.SoundId == "rbxassetid://2588878861" then
	script.Parent.Text = ("kudasai - serenade")
end

if Song.SoundId == "rbxassetid://2586337870" then
	script.Parent.Text = ("kudasai - technicolor")
end

if Song.SoundId == "rbxassetid://4543797183" then
	script.Parent.Text = ("kudasai - technicolor")
end
end

Could you send me a copy of the place? So that I can try it for myself.

1 Like

u can copy it :slight_smile: of course its not the real thing just in case!

It’s copylocked, I can’t see anything

1 Like

You should add a wait() in there, or use .Changed.

I think sound Id returns a string on numbers, so not:

"rbxassetid://366682733"

But,

"366682733"

how to uncopylock??? :neutral_face:

https://www.roblox.com/places/yourgameid/update#
or go to the create tab, navigate to the Place and Configure it, then go to permissions and allow copying

1 Like

Problem is, this has to be a local script or run the code when game.Players.PlayerAdded is run

1 Like

and @WBostonW when there is nothing in PlayerScripts called LocalBackgroundMusic.BGM

strange, because for me there was… did u look in the local player?

Okay this took way to long, with the old code would look through LocalBackgroundMusic to find a Member called BGM not a Child.
Here’s the code btw: Just change the script to a Localscript

local plr = game.Players.LocalPlayer
--local Song = plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM") // -- Will index nil if used in the if-statements?


while wait() do

	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://1587473857" then
		script.Parent.Text = "Current Song: Chill"
	end
	
	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://366682733" then
		script.Parent.Text = "Current Song: Chill2"
	end
	
	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://911100428" then
		script.Parent.Text = "Current Song: idealism lonely"
	end
	
	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://2240495212" then
		script.Parent.Text = "kudasai - attached"
	end
	
	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://2663497976" then
		script.Parent.Text = "kudasai - sapphire"
	end
	
	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://2588878861" then
		script.Parent.Text = "kudasai - serenade"
	end
	
	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://2586337870" then
		script.Parent.Text = "kudasai - technicolor"
	end
	
	if plr.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM").SoundId == "rbxassetid://4543797183" then
		script.Parent.Text = "kudasai - technicolor"
	end
	end

and change line 5 in Listenforchange to:

local song = game.Players.LocalPlayer.PlayerScripts.LocalBackgroundMusic:FindFirstChild("BGM")
Type Description Can fire to
LocalScript For client side and to be used in PlayerBased stuff Client and Server(Using RemoteEvents and RemoteFunctions)

thank you all for your help!!!

@WBostonW also when looking into the code a little bit more: line 4 in OpenAnim should be:

object.AnchorPoint = Vector2.new(-0.100,0.387)