Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with making notification system queue?

Asked by 8 years ago

Ok so im trying to make a notification system that alerts people when ever someone either joins,leaves, or dies. but im having a problem to where when a new notification is received it overwrites the last one.

-- Server script fires event whenever player joins or leaves
game.Players.PlayerAdded:connect(function(player)
    game.workspace.PlayerJoined.PlayerName.Value = player.Name
    game.workspace.PlayerJoined:FireAllClients()
end)

game.Players.PlayerRemoving:connect(function(player)
    game.workspace.PlayerLeft.PlayerName.Value = player.Name
    game.workspace.PlayerLeft:FireAllClients()
end)
--local script then works the magic
---------[Constants]-------------------------------------------------------------------------------

local OPENPOSITION = UDim2.new(1, -200, .75, 0)
local CLOSEPOSITION = UDim2.new(1, 0, .75, 0)
local Queue = 0

---------[End]-------------------------------------------------------------------------------------

function Notify()
    if Queue == 0 then
        local Notification = script.Parent.Notification:clone()
        Notification.Name = "Notification1"
        Notification.Parent = script.Parent
        Notification:TweenPosition(OPENPOSITION, "Out", "Bounce", .5, true)
        Queue = Queue + 1
        wait(5)
        Notification:TweenPosition(CLOSEPOSITION, "Out", "Bounce", .5, true)
        Queue = Queue - 1
    elseif Queue == 1 then
        script.Parent.Notification1.Position.X = script.Parent.Notification1.Position.X + UDim2.new(0, 0, 0, 55)
        local Notification = script.Parent.Notification:clone()
        Notification.Name = "Notification2"
        Notification.Parent = script.Parent
        Notification:TweenPosition(OPENPOSITION, "Out", "Bounce", .5, true)
        Queue = Queue + 1
        wait(5)
        Notification:TweenPosition(CLOSEPOSITION, "Out", "Bounce", .5, true)
        Queue = Queue - 1
    end
end

game.workspace.PlayerJoined.OnClientEvent:connect(function()
    script.Parent.Notification.Text = game.workspace.PlayerJoined.PlayerName.Value .. " has joined."
    Notify()
end)

game.workspace.PlayerLeft.OnClientEvent:connect(function()
    script.Parent.Notification.Text = game.workspace.PlayerLeft.PlayerName.Value .. " has left."
    Notify()
end)


i want it to where everytime the queue goes up by 1 the previous notifications go up by 55. please help me.

Answer this question