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

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

Asked by 4 years ago
Edited 4 years ago

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
0
What is value ? NiniBlackJackQc 1562 — 4y
0
Show your entire script so we can analyze it. Nckripted 580 — 4y
0
It prints out "false" because the music (value) isn't playing. Dan_PanMan 227 — 4y
0
But it is playing music.. Nistrict 44 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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)

Ad
Log in to vote
0
Answered by 4 years ago

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)
0
there not mixed up.. and there is no error anyways. Nistrict 44 — 4y
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 ChrisTheRobloxPlayYT 256 — 4y
0
This error happens Players.ReaIisticaI.PlayerGui.MusicGUI.MusicLabel.LocalScript:11: attempt to index nil with 'GetPropertyChangedSignal' Nistrict 44 — 4y
Log in to vote
0
Answered by 4 years ago

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

0
I dont want the ID name. I want the name I chose. Nistrict 44 — 4y
0
same thing happens with the other answer above..Players.ReaIisticaI.PlayerGui.MusicGUI.MusicLabel.LocalScript:11: attempt to index nil with 'GetPropertyChangedSignal' Nistrict 44 — 4y
0
ok User#29913 36 — 4y

Answer this question