Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I am making a script that will show what music is playing at the moment on a textlabel. Help?

I get no errors but when it prints in the output it says false.. Does anyone know why?

local Music = workspace.LobbyMusic:GetChildren() 
	for key,value in next,Music do
		print(value.IsPlaying)
		if value.IsPlaying == true then
	script.Parent.Text = value.Namename
end

value:GetPropertyChangedSignal("IsPlaying"):Connect(function()
	if value.IsPlaying == true then
		script.Parent.Text = value.Name
		end
	end)
end

4 comments

0

What is value ?

0

Show your entire script so we can analyze it.

0

It prints out "false" because the music (value) isn't playing.

0

But it is playing music..

3 answers

✓ Accepted answer

You got an error at line 5:

script.Parent.Text = value.Namename

Change that to

script.Parent.Text = value.Name

Hope that helped! Edit:

local Music = workspace.LobbyMusic:GetChildren() 
local currentsong
while true do
    for key,value in next,Music do
        print(value.IsPlaying)
        if value.IsPlaying == true then
    script.Parent.Text = value.Name
    currentsong = value
end
wait(currentsong.TimeLength + 1)
end
end

value:GetPropertyChangedSignal("IsPlaying"):Connect(function()
    if value.IsPlaying == true then
        script.Parent.Text = value.Name
        end
    end)

I think your end and end) are a bit messed up.

Use this fix that organizes them, it may fix it:

local Music = workspace.LobbyMusic:GetChildren() 

for key,value in next,Music do
	print(value.IsPlaying)

	if value.IsPlaying == true then
		script.Parent.Text = value.Namename
	end
end

value:GetPropertyChangedSignal("IsPlaying"):Connect(function()
    if value.IsPlaying == true then
        script.Parent.Text = value.Name
    end
end)

3 comments

0

there not mixed up.. and there is no error anyways.

0

you are using an end at an event and an end) at an if statement, use the one i sent and tell me what happens

0

This error happens Players.ReaIisticaI.PlayerGui.MusicGUI.MusicLabel.LocalScript:11: attempt to index nil with 'GetPropertyChangedSignal'

here:

local Music = workspace.LobbyMusic:GetChildren() 
local marketplaceService = game:GetService("MarketplaceService")

for key,value in next,Music do
    print(value.IsPlaying)
    if value.IsPlaying == true then
        script.Parent.Text = marketplaceService:GetProductInfo(Music.SoundId,1).Name
    end
end

value:GetPropertyChangedSignal("IsPlaying"):Connect(function()
    if value.IsPlaying == true then
        script.Parent.Text = marketplaceService:GetProductInfo(Music.SoundId,1).Name
    end
end)

this will show the name of the ID automatically without having to update the name

3 comments

0

I dont want the ID name. I want the name I chose.

0

same thing happens with the other answer above..Players.ReaIisticaI.PlayerGui.MusicGUI.MusicLabel.LocalScript:11: attempt to index nil with 'GetPropertyChangedSignal'

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.