0 views0 copies0 likes

Notification Queue with One Toast at a Time

Universal script

Copy it, then test it in your own Studio place.

UI systems Verified

Script code

23 lines ยท 0.6 KB
Download
local ToastQueue = {}function ToastQueue.New(label)	local queue = {}	local active = false	label.Visible = false	local function worker()		while label.Parent and #queue > 0 do			label.Text = table.remove(queue, 1)			label.Visible = true			task.wait(2)		end		if label.Parent then label.Visible = false end		active = false	end-- โ€ฆopen Get script for the full source

About this script

Require this ModuleScript from a LocalScript and pass an existing TextLabel to New. Call Push on the returned object whenever you want a brief notification. The queue displays one message for two seconds at a time and keeps up to eight pending messages. Send a rapid burst during testing to check ordering before using it with checkpoints or inventory changes.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local ToastQueue = {}
function ToastQueue.New(label)
	local queue = {}
	local active = false
	label.Visible = false
	local function worker()
		while label.Parent and #queue > 0 do
			label.Text = table.remove(queue, 1)
			label.Visible = true
			task.wait(2)
		end
		if label.Parent then label.Visible = false end
		active = false
	end
	local function push(message)
		if typeof(message) ~= "string" or not label.Parent or #queue >= 8 then return false end
		table.insert(queue, message)
		if not active then active = true; task.spawn(worker) end
		return true
	end
	return {Push = push}
end
return ToastQueue