Scrollingframe wont automatically scroll to latest textlabel

hi! so i made a script to scroll down automatically when a new message appears so the latest message can always be seen, but as you can see, it only works 1/2 of the time, strange…

heres the script:

script.Parent.ChildAdded:Connect(function(child)
	if child:IsA("TextLabel") then
		if #script.Parent:GetChildren() >= 13 then
			script.Parent.CanvasPosition = Vector2.new(0, child.AbsolutePosition.Y)
		end
	end
end)

could anyone help me fix this?

i fixed it!

while wait() do
	if #script.Parent:GetChildren() >= 13 then
		print("more")
		script.Parent.CanvasPosition = Vector2.new(0,999999)
	else
		print("less")
	end
end

basically it checks if theres enough elements to fill up the scrolling frame without scrolling down and if so automatically scroll down