Error clearing notification queue

I am trying to add a notification system with a queue. The queue works fine, however the issue is that the clear queue button does not clear the queue.
Any help?

I can’t find any solutions…

-- Define tables
local queue = {}

-- Define tween variables
local Notification = script.Parent.Notification

-- Runs when remote event is fired
game.ReplicatedStorage.Notify.OnClientEvent:Connect(function(TitleText, DescriptionText, interval, delaytime)
	-- Clone notification and set text
	local NewNotification = Notification:Clone()
	local ClearQueue = NewNotification.ClearQueue
	
	table.insert(queue, NewNotification)
	NewNotification.Title.Text = TitleText
	NewNotification.Description.Text = DescriptionText
	NewNotification.Parent = Notification.Parent
	
	ClearQueue.Activated:Connect(function()
		table.clear()
	end)

Most of the code to make the notification work is not included, as that isn’t important and is functioning fine

You need to pass the table to be cleared as a parameter, e.g.

table.clear(queue)



This is gonna make a new connection each time the event is fired, you should probably move this outside of the event connection.

It has to be in the connection because a new notification is cloned, and it needs to be in the connection to pass the new notification as a parameter for the location of the new button.

1 Like

If it only needs to be used once, use :Once instead of :Connect.

But it looks like all the connection is doing is clearing the queue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.