When clicking 2 of the alert activation parts, and after the first alert plays, an error occurs and I don’t know why it’s getting nil when it clearly inserts the data into the Queue
table.
Error:
GUI Module:
local GUI = {}
local Queue = {}
local TweenService = game:GetService("TweenService")
local TransitionInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad)
local IsAlerting = false
function GUI.Alert(Text, Time, Color, Player)
if IsAlerting then
table.insert(Queue, {Text, Time, Color, Player})
return
end
IsAlerting = true
local AlertLabel = script.Assets.AlertLabel
local NewAlertLabel = AlertLabel:Clone()
NewAlertLabel.Name = "Alert"
NewAlertLabel.BackgroundColor3 = Color
NewAlertLabel.Text = Text
NewAlertLabel.Parent = game.Players[tostring(Player)].PlayerGui.Notifacation.GUIHolder
TweenService:Create(NewAlertLabel, TransitionInfo, {BackgroundTransparency = 0}):Play()
TweenService:Create(NewAlertLabel, TransitionInfo, {TextTransparency = 0}):Play()
local TweenWait = TweenService:Create(NewAlertLabel, TransitionInfo, {Position = UDim2.new(0.5, 0, 0.94, 0)})
TweenWait:Play()
TweenWait.Completed:Connect(function()
wait(Time)
TweenService:Create(NewAlertLabel, TransitionInfo, {BackgroundTransparency = 1}):Play()
TweenService:Create(NewAlertLabel, TransitionInfo, {TextTransparency = 1}):Play()
local TweenWait = TweenService:Create(NewAlertLabel, TransitionInfo, {Position = UDim2.new(0.5, 0, 0.88, 0)})
TweenWait:Play()
TweenWait.Completed:Connect(function()
NewAlertLabel:Destroy()
task.wait()
IsAlerting = false
if #Queue >= 1 then
table.remove(Queue, 1)
wait(0.5)
GUI.Alert(table.unpack(Queue[1])) --Error line #38
end
end)
end)
end
return GUI
Snippet of the 2 activation parts (module):
function Restock.ColdDrinkCup(Player, ItemPath)
deletesoon_guimodule.Alert("Sorry but the Cold Drink Cup restock item isn't available at this time!", 5, Color3.fromRGB(255, 34, 34), Player)
end
function Restock.TakeawayCup(Player, ItemPath)
deletesoon_guimodule.Alert("Sorry but the Takeaway Cup restock item isn't available at this time!", 5, Color3.fromRGB(255, 34, 34), Player)
end