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

How to play multiple instances of the same tween at once?

Asked by 2 years ago

I am making a notification system for my game. When there is a new notification with one already existing, it will show up above the previous notification. It does this until there are no more notifications.

This is what I'm trying to do. ^

I want to play the same animation for all of the notifications because, well, they're the exact same. But I don't know how to do this in a function without making multiple functions that serve no other purpose than being there for the excess notifications. Here's the code (The closest that I've gotten to getting what I wanted.)

function Notification(text, name, num)
    -- vars
    local screengui = game.Players.LocalPlayer.PlayerGui.ScreenGui
    local noti = screengui.Main.NotificationUI[name]
    -- vars/calcs
    -- open
    noti.notiText.Text = text
    noti:TweenPosition(UDim2.new(1, -300,num, 0),"Out","Quad",1, false) 
    noti.Timed.timeInPlace:TweenSize(UDim2.new(1, 0,0, 3),"Out","Linear",2.5, false)
    -- exit
    noti:TweenPosition(UDim2.new(1, 0,num, 0),"In","Quad",0.8, false)
    -- change bar back to place
    noti.Timed.timeInPlace.Size = UDim2.new(0, 0,0, 3)
end

This code will play the animation for each notification. If multiple notifications play at one time, it either doesn't show up at all (If I turn override to true) or they don't retract back to where they're supposed to be.

I'm quite new to LUA so go easy on me if there's a simple fix for this.

Answer this question