Recently I found out that the current script below (without the comments) was a ‘server’ queue. Meaning that when the function was called more than once it would queue on the server when it should queue on the client, causing a mess. This would affect things like: when I would update the game only 1 person at a time got the alert.
How can I go about fixing this? LocalScripts and ServerScripts require this module and use it for different purposes.
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
wait(0.25)
GUI.Alert(table.unpack(table.remove(Queue, 1)))
end]]
end)
end)
end
return GUI```