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

How to control all objects that have the same name?

Asked by 8 years ago

i need help with a script where i need it to get all the objects by the name of "Notification" with the exception for the very bottom one and subtract 55 from their y axis.

---------[Constants]-------------------------------------------------------------------------------

local X = -200
local XCLOSE = 200
local Y = 355
local YCLOSE = 355
local YMINUS = 0
local Queue = 0

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

function Notify()
    if Queue == 0 then
        local Notification = script.Parent.NotificationORIGINAL:clone()
        Notification.Name = "Notification"
        Notification.Parent = script.Parent
        Notification:TweenPosition(UDim2.new(1, X, 0, Y), "Out", "Bounce", .5, true)
        Queue = Queue + 1
        wait(5)
        Notification:TweenPosition(UDim2.new(1, XCLOSE, 0, YCLOSE), "Out", "Bounce", .5, true)
        wait(1)
        Notification:Destroy()
        Queue = Queue - 1
    else
        YMINUS = 55 * Queue
        script.Parent.Notification:TweenPosition(UDim2.new(1, X, 0, Y-YMINUS), "Out", "Back", .5, true)
        YCLOSE = YCLOSE-YMINUS
        local Notification = script.Parent.NotificationORIGINAL:clone()
        Notification.Name = "Notification"
        Notification.Parent = script.Parent
        Notification:TweenPosition(UDim2.new(1, X, 0, Y), "Out", "Bounce", .5, true)
        Queue = Queue + 1
        wait(5)
        Notification:TweenPosition(UDim2.new(1, XCLOSE, 0, Y), "Out", "Bounce", .5, true)
        wait(1)
        Queue = Queue - 1
        Notification:Destroy()
    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)


Answer this question