Issue with UI pop-up

Hello, I made a UI to show text labels when an “item is added,” but there are some issues with it.

When I change the speed at which the text labels are parented to the GUI to anything above .35 seconds, the tweening starts to bug out.
2022-03-29 01-15-18 (Creating a text label every .25 seconds)
2022-03-29 01-15-43 (Creating a text label every .5 seconds)

Couldn’t find any related topics, so I’ve resorted to making one.

local TweenService = game:GetService('TweenService')

-- // Variables

local Gui = script.Parent.ScreenGui

local Tweening = {} 
local Heading = {}
local Next = {}

-- // Functions

local function TextAdded(Label)
	local Number = #Gui:GetChildren()
	
	Label.Name = Number
	
	local HeadingPosition = UDim2.new(.4, 0, Label.Size.Y.Scale * Number, 0)
	
	local Tween = TweenService:Create(Label, TweenInfo.new(.25), {Position = UDim2.new(.4, 0, HeadingPosition, 0)})
	if Gui:FindFirstChild(Number - 1) then
		if Heading[Number - 1] then
			Tween = TweenService:Create(Label, TweenInfo.new(.5), {Position = Heading[Number - 1]})
			HeadingPosition = Heading[Number - 1] + UDim2.new(0, 0, Label.Size.Y.Scale, 0)
		end
	end
	Tween:Play()
	
	Tweening[Label] = Tween
	Heading[Number] = HeadingPosition
	
end

local function TextRemoved(Label)
	if Tweening[Label] then
		Tweening[Label]:Cancel()
	end
	
	for i = 1, #Gui:GetChildren() do
		local NextPostion = Gui[i].Position + UDim2.new(0, 0, -Gui[i].Size.Y.Scale, 0)
		
		if Tweening[Gui[i]] then
				Tweening[Gui[i]]:Cancel()
			end
				if Gui:FindFirstChild(i - 1) then
					if Next[Gui[i - 1]] then
						NextPostion = Next[Gui[i - 1]] + UDim2.new(0, 0, Gui[i - 1].Size.Y.Scale, 0)
					end
				end
				
				Next[Gui[i]] = NextPostion

		if Gui[i]:FindFirstChild('Removing') then
			Next[Label] = Label.Position + UDim2.new(0, 0, -Label.Size.Y.Scale, 0)
			TweenService:Create(Label, TweenInfo.new(.25), {Position = Label.Position + UDim2.new(-1, 0, 0, 0)}):Play()
		else
			
			if Tweening[Gui[i]] then
				Tweening[Gui[i]]:Cancel()
			end
			
			local Tween = TweenService:Create(Gui[i], TweenInfo.new(.25), {Position = NextPostion})
			Tweening[Gui[i]] = Tween
			Tween:Play()
		end

		end
	end

-- // Run Code

Gui.ChildAdded:Connect(TextAdded)

wait(3)

for i = 1, 20 do
	local TextLabel = game.ReplicatedStorage.TextLabel:Clone()
	TextLabel.Parent = Gui
	
	spawn(function()
		wait(2)
		local Removing = Instance.new('BoolValue', TextLabel)
		Removing.Name = 'Removing'
		
		TextRemoved(TextLabel)
	end)
	
	wait(.5)
end

If you have any solutions, please let me know.

it looks like the issue is because your TextRemoved has a delay in removing the TextLabel from Gui, so if you make a Text while one is being removed #Gui, or Number, is incorrect

maybe try removing the Text from the gui and placing it in abother GuiObject at the same position before playing the remove tween would fix this

I figured out the issue already. Thank you for replying though. Sorry for wasting your time.