Bindable Event Issue

Right now, I am currently trying to make a jukebox that will add songs to a queue when requested by players. For some reason, one bindable event won’t fire. There are no errors in the output, it just won’t fire the function.

Here are the 2 scripts that involve this bindable event;

Queue Manager:

Click Me
local remote = repStorage.MusicTransfer
local songdone = repStorage.NextSong
local queuesubmit = repStorage.QueueSubmit

local queue = {}


remote.OnServerEvent:Connect(function(plr, msg)
	print("got request")
	local tablenumber = table.getn(queue)
	table.insert(queue, tablenumber + 1, msg)
end)

songdone.Event:Connect(function()
	print("got done")
	local tablenumber = table.getn(queue)
	if tablenumber == 0 then
		print("no song in queue")
		queuesubmit:Fire(false)
	else
		print("song in queue; sending")
		print(queue[1])
		queuesubmit:Fire(queue[1]) -- THIS IS THE CALLER 
		table.remove(queue, 1)
		print("song sent")
	end
end)

Jukebox Manager:

Click Me
local songdone = repstorage.NextSong
local queuesubmit = repstorage.QueueSubmit
local audio = workspace.SoundRegion.Audio

local autosongs = {6609420237}

while true do
	-- pick random song
	
	local randnum = math.random(1,1)
	for i,v in pairs(autosongs) do
		if i == randnum then
			-- load song
			
			audio.SoundId = "rbxassetid://"..v
			wait(2)
			wait(audio.TimeLength)
			songdone:Fire()
			queuesubmit.Event:Connect(function(msg) -- THIS IS THE FUNCTION THAT WILL NOT CALL
				print("got queue response")
				if msg == false then
					print("no song in queue response")
				else
					print("got queue song response")
					audio.SoundId = "rbxassetid://"..msg
					wait(2)
					wait(audio.TimeLength)
					songdone:Fire()
					return
				end
			end)
		end
	end
end

If you know an easier way to make a system like this or you know the specific issue, please let me know!


I didn’t, I called it with this.

At this point, I would get rid of bad habits such as not utilizing :FindFirstChild(), which I understand if you are a new scripter. variable.variable.property is not very efficient to use, even though some people say this way is faster, it is not a good practice overall.

variable.property should be the correct way. For example:

local var = script:FindFirstChild("Script")
var.Disabled = true   –– variable.property

Fixing small habits that are big in the longterm should help you with your coding. It is not shameful to use DevHub | Roblox, so keep using it to help guide you. Once done, you should remake it from scratch or at least try to fix it. I would use local success, result = pcall ... to catch errors.

local success, result = pcall(function())
    ––your code here
end
if not success then
    warn(result)
end