Animation.Stopped:Connect() causing weird duplication

So for some reason whenever I call the Animation.Stopped event it results in duplication.

	local Anim = Instance.new("Animation", script)
	Anim.AnimationId = "rbxassetid://6686813062"
	local AnimAnim = Humanoid:FindFirstChild("Animator"):LoadAnimation(Anim)

	local function playAnim()
			AnimAnim:Play()

			AnimAnim.Stopped:Connect(function()
				print("Hi!")
            end)
     end

“Hi” would print once, then twice, then three times, etc.

Any help?

Nvm figured it out. I simply need to disconnect the function after calling it.

Example here:

	local Anim = Instance.new("Animation", script)
	Anim.AnimationId = "rbxassetid://6686813062"
	local AnimAnim = Humanoid:FindFirstChild("Animator"):LoadAnimation(Anim)

	local function playAnim()
			AnimAnim:Play()

			AnimFunction = AnimAnim.Stopped:Connect(function()
				print("Hi!")
                AnimFunction:Disconnect()
            end)
     end