I am creating a combo counter for my game and Im having the counter pulse via tweens when you get a combo. I achieve this by modifying the X and Y values for the size offset which makes it grow then shrink by a set amount. The problem is you can get many combos in a quick succession so one tween will start to grow the UI element however the next one will immediately start ending the one that is currently going so it will be unable to shrink back down to its original size. Im wondering if theres a way to test when a tween gets canceled, because .Completed will never fire. Heres an example of my code.
function Gui:Pulse(args)
local ui = args.Ui
local duration = args.Duration or 0.5
local size = args.Size or 50
local easingStyle = args.EasingStyle or Enum.EasingStyle.Circular
local tinfo = TweenInfo.new(duration/2, easingStyle)
TweenService:Create(ui, tinfo, {Size = UDim2.new(ui.Size.X.Scale, ui.Size.X.Offset+size, ui.Size.Y.Scale, ui.Size.Y.Offset+size)}):Play()
task.delay(duration/2, function()
-- This tween most of the time wont complete due to other ones firing as this plays
TweenService:Create(ui, tinfo, {Size = UDim2.new(ui.Size.X.Scale, ui.Size.X.Offset-size, ui.Size.Y.Scale, ui.Size.Y.Offset-size)}):Play()
end)
end