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:. Thanks in advance!
(Sorry if my issue is hard to understand, I can also send a video if someone wants to)