You can write your topic however you want, but you need to answer these questions:
- I would like to know what’s causing this error.
- One thing I’ve tried is (If v ~= nil then
else
“Code would be here”
end)
But when I’ve tried this the Update function doesn’t remove the queuing notification form the queue table.
If you can help me that would be greatly appreciated, Thanks!
(Sorry if this code is messy havent organized it yet )
local TweenService = game:GetService("TweenService")
local NotificationsInQueue = {}
local ActiveNotifications = 0
local NotificationLimit = 3
local ActiveTime = 6
local QueueNum = #NotificationsInQueue
local NotificationBox = script.Parent.Storage:WaitForChild("NotificationBox")
local NotificationSounds = script.Parent:WaitForChild("GUISounds")
--//Pushes the notification out
local function Push(Lable, Text, Sound)
task.spawn(function()
table.remove(NotificationsInQueue[1])
print("yea")
for _,i in pairs(script.Parent.Holder:GetChildren()) do
if i:IsA("Frame") then
i:TweenPosition(UDim2.new(0,0, i.Position.Y.Scale - .300, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad,.3)
end
end
local Clone = NotificationBox:Clone()
ActiveNotifications = ActiveNotifications + 1
task.wait(.7)
Clone.Parent = script.Parent.Holder
Clone.Lable.Text = Lable
Clone.Text.Text = Text
Clone:TweenPosition(UDim2.new(0,0, Clone.Position.Y.Scale, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad,.3)
if Sound == "None" then
NotificationSounds.none:Play()
elseif Sound == "Error" then
NotificationSounds.error:Play()
elseif Sound == "Blop" then
NotificationSounds.blop:Play()
end
task.spawn(function()
task.wait(.3)
task.wait(ActiveTime)
Clone:TweenPosition(UDim2.new(1,0, Clone.Position.Y.Scale, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad,.3)
task.wait(1)
ActiveNotifications = ActiveNotifications - 1
Clone:Destroy()
end)
end)
end
--//Puts notification into queue
local function FireNotification(Lable, Text, Sound)
print("yea")
table.insert(NotificationsInQueue,{#NotificationsInQueue+1,["Lable"] = Lable; ["Text"] = Text; ["Sound"] = Sound})
print("yea")
end
--//Error is happening here
local function Update()
if ActiveNotifications < NotificationLimit and #NotificationsInQueue > 0 then
Push(NotificationsInQueue[1].Lable, NotificationsInQueue[1].Text, NotificationsInQueue[1].Sound)
task.wait()
for i, v in pairs(NotificationsInQueue) do
v = v - 1
end
end
end
task.spawn(function()
while task.wait(1.40) do
Update()
end
end)
Feel free to ask me any further questions. Thanks again.