Animation Handler System not working properly

Hi, I am currently working on an Animation Handler System, however I have run into an issue. The script will only check what is equipped at the start and will not check if a different animation is equipped or no animation is equipped. How can I fix this?

Each animation folder is placed into every players character.

Script:

local replicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local AttackAnimationsFolder = replicatedStorage:WaitForChild("AttackAnimations")

local function SearchForEquippedAttackAnimation(player)
	local character = player.Character
	if character then
		local animationFolder = character:FindFirstChild("AttackAnimations")
		if animationFolder then
			for _, child in pairs(animationFolder:GetChildren()) do
				if child:IsA("Animation") then
					local equippedValue = child:WaitForChild("EquippedValue")
					if equippedValue:IsA("BoolValue") and equippedValue.Value == true then
						return child
					end
				end
			end
		end
	end
end

local function CheckEquippedAnimation(player)
	local equippedAnimation = SearchForEquippedAttackAnimation(player)
	if equippedAnimation then
		print(player.Name .. " has equipped: " .. equippedAnimation.Name)
	else
		print(player.Name .. " has no equipped animation.")
	end
end

local function HandleEquippedValueChanged(animation)
	local equippedValue = animation:WaitForChild("EquippedValue")
		if equippedValue.Value == false then
	
		for _, player in pairs(Players:GetPlayers()) do
			if player then
				CheckEquippedAnimation(player)
			end
		end
	end
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		local animationFolder = AttackAnimationsFolder:Clone()
		animationFolder.Parent = player.Character
		CheckEquippedAnimation(player)
	end)
end)

RunService.Heartbeat:Connect(function()
	task.wait(1)
	for _, player in pairs(Players:GetPlayers()) do
		local animationFolder = player.Character:FindFirstChild("AttackAnimations")
		if animationFolder then
			for _, child in pairs(animationFolder:GetChildren()) do
				if child:IsA("Animation") then
					HandleEquippedValueChanged(child)
				end
			end
		end
	end
end)

This part of your code is an absolute disaster considering the nests are completely mad.
Also,

This is the worst nesting I’ve EVER seen, consider making this one cleaner? Nesting for 3 or more times are already very bad.

As of your problem, I’m not too sure yet since your code is very huge and I don’t have the things required for testing it myself, while trying to search for an error in your code will take literally too much time.

But maybe atleast fix the nestings of my first quoting and see if anything differs