Notification System Help

Hello developers,
I’m currently trying to make a notification system, where the server sends notifications to the client, and the client gets a quick message that shows the notification. But, I want it so if there is more than one notification, the TextLabels don’t overlap. This is what I’ve got so far:

local events = game.ReplicatedStorage
local notificationsinqueue = 0
local tweenservice = game:GetService("TweenService")
local tme = 7
wait()
events.NotificationAllClientsEvent.OnClientEvent:Connect(function(notification)
	notificationsinqueue = notificationsinqueue + 1
	local y = notificationsinqueue * 0.1 + 0.05
	local clone = script.Parent.NotificationLabel:Clone()
	clone.Text= "Clone"
	clone.Position = UDim2.new(0.5,0,-0.05,0)
	clone.Parent = script.Parent
	clone.Text = notification
	local goal = {}
	goal.Position = UDim2.new(0.5,0,y, 0)
	local tweeninfo = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
	local tween = tweenservice:Create(clone, tweeninfo, goal)
	tween:Play()
	local currentnotinque = notificationsinqueue
	while tme >= 0 do
		tme = tme - 0.1
		if currentnotinque > notificationsinqueue then
			local desc = script.Parent:GetDescendants()
			for i = 1, #desc do
				if desc[i].Name == "Clone" then
					local clone1 = desc[i]
					local y = notificationsinqueue * 0.1 + 0.05 - 0.1
					local goal1 = {}
					goal1.Position = UDim2.new(0.5,0,y, 0)
					local tweeninfo1 = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
					local tween1 = tweenservice:Create(clone1, tweeninfo1, goal1)
					tween1:Play()
				end
			end
		end
		currentnotinque = notificationsinqueue
	end
	tme = 5
		task.wait(0.1)
	local goal1 = {}
	goal1.Position = UDim2.new(1.5,0,y, 0)
	local tweeninfo1 = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	local tween1 = tweenservice:Create(clone, tweeninfo1, goal1)
	tween1:Play()
	task.wait(1)
	notificationsinqueue = notificationsinqueue - 1
	clone:Destroy()
end)

For some reason, when a notification disappears, the other notifications don’t move up like they’re suppose to. And after some time, all notifications just get overlapped, and I’ve been trying to fix this for hours. Any help is greatly appreaciated​:grinning::grinning:. Thanks in advance!
(Sorry if my issue is hard to understand, I can also send a video if someone wants to)

Yes, please send a video of your issue. It’s very hard to see what’s going on in the script without seeing the result of it running.

Okay, I‘ll send it tomorrow. Thanks for replying!

I assume you want the notifications to stack on top of each other.
Make a new Frame as a “Container” to hold your notifications. Add a UIListLayout object to it. Then, each time a new notification is received, add it inside that container and remove it after a few seconds. As more are added they will stack automatically.

2 Likes

Yes, but you should also set the GUIObject's LayoutOrder to order them correctly. More info.

1 Like

I’ll go ahead and try that. Thanks for the reply!

I’ll look into this after I try @Apicphis 's method. Thanks for the message tho!

1 Like

Hey @Apicphis ,
I finally got it working! Thanks for your reply😀! I really appreaciate it!

Hey @calvin_coco ,
I used that method as well and I think UIListLayout is a really cool feature. Again, thanks you both for the replies!

1 Like

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