Event subscription not running

In this code, the event bind never runs.

function activityMan.scriptSpawnWindow(caller: LocalScript, icon, name, alwaysOnTop, noCloseButton, parameters)
	
	local window = windowMan.spawnWindow(caller, name, icon, alwaysOnTop, noCloseButton, parameters)
	
	scriptDestroyListners[#scriptDestroyListners+1] = caller.Destroying:Connect(function()
		windowMan.closeWindow(window.Parent:GetAttribute("windowID"))

	end)
	return window
end

It is in a modulescript. I can’t find any information on if modulescripts can receive events.

Any errors from the output? Could you possibly show the script that calls this function from the module?

The function is being called since the other code executes, no console output.

try using table.insert() rather thans criptDestroyListeners[#scriptDestroyListeners+1]

assuming this has nothing to do with it but “Listeners” is spelled wrong:
image

Thanks for pointing out the spelling mistake. Midnight coding lol.

I tried table.insert({}…,caller…) but still no dice

When printing the contents of the table, “*cannot read value as a string” the table was empty before so at least there is something there. Printing table[1].Connected returns true

I validated that “caller” was indeed the script by printer caller.name. I honestly have no idea how to proceed, this has stumped me for a few days.

.Destroying() has never worked as intended so try listening for :GetPropertyChangedSignal() on the parent maybe?

table.insert(scriptDestroyListeners, caller:GetPropertyChangedSignal("Parent"):Connect(function()
    if caller.Parent == nil then
        windowMan.closeWindow(window.Parent:GetAttribute("windowID"))
    end
end))
function activityMan.scriptSpawnWindow(caller: LocalScript, icon, name, alwaysOnTop, noCloseButton, parameters)
	
	local window = windowMan.spawnWindow(caller, name, icon, alwaysOnTop, noCloseButton, parameters)
	print(caller.Name)
	
	table.insert(scriptDestroyListeners,caller:GetPropertyChangedSignal("Parent"):Connect(function()
		
		if caller.Parent == nil then
			windowMan.closeWindow(window.Parent:GetAttribute("windowID"))
		else
			print("parent changed not nil")
		end
	
	end))
	print(scriptDestroyListeners[1].Connected)
	return window
end

Still not working…

3 questions:

1.) Is the signal even firing in the first place? (even if the parent is not nil)
2.) Are you destroying the LocalScript from the client or the server
3.) is this module required from the client or the server

module required from client, script destroyed on client.
Event is not firing as the code on snippet line 11 is not printing

Anybody have an idea on why this is happening?