So I currently have a working kill indicator GUI for players with tween transparent animations, basically when you kill a player a text label pops up saying “killed {name}” for 3 seconds, but the only issue is that whenever I kill more than one person within 3 seconds, the first tween’s transparency animation overrides the 2nd tween’s animations, making it appear for less time. How can I fix this so that the tween animations wont interrupt each other?
-- // Services
-- External services
local tweenService = game:GetService("TweenService")
-- Default services
local replicatedStorage = game:GetService("ReplicatedStorage")
local playersService = game:GetService("Players")
-- // Variables
-- Comms variables
local killEvent = replicatedStorage:WaitForChild("KillNotification")
-- Player variables
local player = playersService.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- UI variables
local killGUI = script.Parent
local notification = killGUI:WaitForChild("Notification")
local killSound = script:WaitForChild("KillSound")
-- // Functions
local function tweenTransparency(guiObject, duration, transparency, Override)
spawn(function()
local tween = nil
if guiObject:IsA("TextLabel") then
local tween = tweenService:Create(guiObject, TweenInfo.new(duration), {TextTransparency = transparency}, {Override = Override})
tween:Play()
spawn(function()
tween.Completed:Wait()
tween:Destroy()
end)
elseif guiObject:IsA("ImageLabel") then
local tween = tweenService:Create(guiObject, TweenInfo.new(duration), {ImageTransparency = transparency}, {Override = Override})
tween:Play()
spawn(function()
tween.Completed:Wait()
tween:Destroy()
end)
end
if tween ~= nil then
return tween
end
end)
end
local function notify(victim)
notification.TextTransparency = 1
notification.Text = "<font color='#ff3a3a'>Eliminated: </font>" .. victim.Name
killSound:Play()
tweenTransparency(notification, 0.5, 0, true)
notification:TweenSize(UDim2.new(0.302, 0, 0.052, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
wait(0.1)
notification:TweenSize(UDim2.new(0.216, 0, 0.037, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
wait(3)
tweenTransparency(notification, 0.5, 1, true)
end
-- // Connection