Attempting to change where audio is being pulled from

I am rewriting my script to pull from workspace.sound.music.radio instead of just script.Parent:GetChildren() IsA(“Sound”) I have got it to pull the song names the issue is with trying to get it to play the songs, I am getting a stack start/end error on line 2 of this script

for i,v in pairs(workspace.Sound.Music.Radio:GetChildren()) do
    v.MouseButton1Click:connect(function()
        check = workspace.Sound.Music.Radio:FindFirstChild(v.Name)
        if check == nil then
            print("error")
        elseif check ~= nil then
            if script.Parent.CurrentSound.Value ~= v.Name then
                for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
                    if v:IsA("Sound") then
                        v:Stop()
                    end
                end
                script.Parent.Collector.Current.Text = "Now Playing: "..v.Name
                script.Parent.CurrentSound.Value = v.Name
                --Update Sound ID UI
                    local split = string.split(check.SoundId,"//")
                        script.Parent.AudioIDGUI.TextLabel.Text = split[2]
    
                check.Looped = true
                check:Play()
                script.Parent.Parent.Parent.PointLight.Enabled = true
                script.Parent.Parent.Parent.PointLight.Script.Disabled = false
            end
        end
    end)
end

--102121711
--102121700

Files, Old one is the unmodded/working version
old jukebox.rbxm (18.1 KB)
Broken music play w sound folder.rbxm (21.6 KB)

1 Like

Structure of files if anyone wants to know

Try printing the classname of the v variable. The error probably means v does not have the MouseButton1Click event.

I am fairly new to lua, I can read it but not write it, how would I go about this (FYI this code is framework from a 2016 model)

Is that sound are you having problem with?

And what’s dev console saying?

I have no idea what that is

And the dev console
image

1: Likely not editing folder position to just sounds.

Can you elaborate on this please

The issue is you’re trying to get the .MouseButton1Click signal from a Sound, which is not a GuiButton. Since your AddSounds script creates GuiButtons from the sounds it finds in that folder, you should connect .MouseButton1Click to those GuiButtons in the Select script using :FindFirstChild

What line of code should the :findfirstchild go on

Actually judging by how you set it up, instead of looping through the sounds in the Select script, I would loop through the GuiButtons in script.Parent.Sounds:GetChildren() in the Select script. Once you do that .MouseButton1Click will work. Inside that event just use :FindFirstChild under the part where all the sounds are stored and it should play the associated sound.