Script Confusion

Im making a touch ball game but when i fix a error creates a new error

What happens is that when I fix an error that the ball does not roll infinitely and that it stops automatically after a while, but when it is fixed and I try to fix the coldown when hitting the ball, it ruins the one that I have already fixed

BallLogic script goes in the ball

local Main = {
	Ball = script.Parent,
	Cooldown = false,
}

local MAX_STOPPING_TIME = 2 -- Tiempo máximo para detener el balón 

Main.Ball.Touched:Connect(function(Touch)
	local Character = Touch.Parent
	if not Character then return "No Character" end

	local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
	local Humanoid = Character:FindFirstChildOfClass("Humanoid")
	local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
	if not Player or not Humanoid or Humanoid.Health <= 0 or not HumanoidRootPart then return "No Access" end

	local BallVelocity = Main.Ball.AssemblyLinearVelocity
	local LookVector = HumanoidRootPart.CFrame.LookVector
	local WalkSpeed = Humanoid.WalkSpeed

	if Main.Ball:GetAttribute("Kicked") == false and Main.Cooldown == false then
		Main.Cooldown = true
		Main.Ball:SetAttribute("Kicked", true)
		Main.Ball:SetNetworkOwner()
		Main.Ball.AssemblyLinearVelocity = (LookVector.Unit * WalkSpeed * 1.95) + Vector3.new(0, WalkSpeed * 1.15, 0)
		task.wait(0.5)

		local stoppingTime = 0
		local startTime = tick()
		while stoppingTime < MAX_STOPPING_TIME do
			local currentTime = tick()
			local elapsedTime = currentTime - startTime
			stoppingTime = elapsedTime
			Main.Ball.AssemblyLinearVelocity = Main.Ball.AssemblyLinearVelocity * 0.9 -- Reducir gradualmente la velocidad del balón
			task.wait()
		end

		Main.Ball.AssemblyLinearVelocity = Vector3.new(0, 0, 0) -- Detener completamente el balón
		Main.Cooldown = false
		Main.Ball:SetAttribute("Kicked", false)

		if Main.Ball:GetAttribute('LastTouch') ~= nil then
			if Main.Ball:GetAttribute('LastTouch') ~= Player.Name then
				local previousTouch = Main.Ball:GetAttribute('LastTouch')
				Main.Ball:SetAttribute('LastTouch', Player.Name)
				Main.Ball:SetAttribute('SecondTouch', previousTouch)
			end
		else
			Main.Ball:SetAttribute('LastTouch', Player.Name)
		end
	end
end)

and Logic goes on Serverscriptservice

-- // Services

local Services = {
	Workspace = game:GetService("Workspace"),
	ReplicatedStorage = game:GetService("ReplicatedStorage"),
	Players = game:GetService("Players")
}

-- // Functions

local function retrieveService(Service)
	return Services[Service]
end

-- // Variables

local TouchCooldown = false
local Ball = nil

-- // Ball Logic

retrieveService("Workspace").ChildAdded:Connect(function(Object)
	if Object.Name == "Ball" and Object:GetAttribute("Kicked") then
		Ball = Object
	end
end)

retrieveService("ReplicatedStorage").Events.BallTouch.OnServerEvent:Connect(function(Player)
	if retrieveService("Workspace")[Ball]:GetAttribute("Kicked") then return end
end)