Damage Error... AGAIN (I swear I'm going to break my keyboard)

Hello again… yeah, again. This time I managed to solve the problem of him walking and applying damage all the time, the object in the end did not self-destruct. With everything, now the Code no longer wants to apply damage after I press C. I was trying to do a double check so that it would recognize if I was going to press the button or not, but it was to take it the same way. If anyone has a method I can resolve this damage conflict, I’d appreciate it.

Stomp:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local pisarEnabled = false -- Variable to control if the stomping is enabled

local kickAnimationId = "13874028312" -- Kick animation ID

local damageAmount = 100 -- Damage value to be applied

-- Function to apply damage to the object
local function ApplyDamageToObject(object)
	local vidaDeObjetos = object:FindFirstChild("Vida de objetos")
	if vidaDeObjetos then
		ReplicatedStorage:WaitForChild("DamageServer"):FireServer(vidaDeObjetos, damageAmount) -- Sends the damage signal to the object with the damage value
	end
end

-- Function to play the kick animation
local function PlayAnimation(animationId)
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://" .. animationId

	local track = humanoid:LoadAnimation(animation)
	track:Play()

	return track
end

-- Function to toggle the stomping feature
local function TogglePisar()
	if not pisarEnabled then
		-- Enable stomping
		pisarEnabled = true
		humanoid.WalkSpeed = 0 -- Set the walk speed to 0
		local kickAnimationTrack = PlayAnimation(kickAnimationId) -- Play the kick animation
		kickAnimationTrack.Stopped:Connect(function()
			pisarEnabled = false -- Disable stomping after the animation finishes
			humanoid.WalkSpeed = 16 -- Restore the default walk speed
		end)
	end
end

-- Connect the toggle function to the C key input event
UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C then
		TogglePisar()
	end
end)

-- Function to check if a part is the right foot
local function IsRightFoot(part)
	return part == humanoid.RightFoot or part:IsDescendantOf(humanoid.RightFoot)
end

-- Connect the damage function to triggering when the right foot touches an object only when stomping is enabled and the C key is pressed
character.DescendantAdded:Connect(function(descendant)
	if IsRightFoot(descendant) then
		descendant.Touched:Connect(function(part)
			if pisarEnabled and UserInputService:IsKeyDown(Enum.KeyCode.C) then
				local object = part.Parent
				ApplyDamageToObject(object) -- Apply damage to the touched object
			end
		end)
	end
end)

Health Object

local object = script.Parent
local health = object:FindFirstChild("Health")

if not health then
	health = Instance.new("IntValue")
	health.Name = "Health"
	health.Value = 1
	health.Parent = object
end

local canTouch = true


local function TakeDamage(damageAmount)
	health.Value = health.Value - damageAmount
	if health.Value <= 0 then
		object:Destroy()
	end
end

object.Touched:Connect(function(part)
	local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
	local player = game.Players:GetPlayerFromCharacter(part.Parent)
	local character = player and player.Character

	if humanoid and player and character then
		local rightFoot = character:FindFirstChild("RightFoot")
		if rightFoot and part == rightFoot then
			
		end
	end
end)

Relax bro no need to break anything, I think the problem is here:

if pisarEnabled and UserInputService:IsKeyDown(Enum.KeyCode.C) then

In this case, for the object to take damage the player should hold the C key, I did a little of optimisation to your code hope it will work for you, they are explained:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local pisarEnabled = false -- Variable to control if the stomping is enabled

local kickAnimationId = "13874028312" -- Kick animation ID


-- Function to apply damage to the object
local function ApplyDamageToObject(object)
	ReplicatedStorage:WaitForChild("DamageServer"):FireServer(vidaDeObjetos) -- Sends the damage signal to the object with the damage value
end

-- Function to play the kick animation
local function PlayAnimation(animationId)
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://" .. animationId

	local track = humanoid:LoadAnimation(animation)
	track:Play()

	return track
end

-- Function to check if a part is the right foot
local function IsRightFoot(part)
	return part == humanoid.RightFoot or part:IsDescendantOf(humanoid.RightFoot)
end

-- Function to toggle the stomping feature
local function TogglePisar()
	if not pisarEnabled then
		-- Enable stomping
		pisarEnabled = true

        local touchEvents = {} --Table to store the touch events
		--Here we should check when a part of the character has been touched.
        for _,v in ipairs(character:GetDescendants()) do
            if IsRightFoot(v) then
            	touchev = v.Touched:Connect(function(part) --Detect when the right foot touched.
                    local vidaDeObjetos = part:FindFirstChild("Vida de objetos")
                    if vidaDeObjetos then --Check if the touched part is one of the objects to hit.
						ApplyDamageToObject(part) --Applying the damage to the part.
						for i,v in ipairs(touchEvents) do
							v:Disconnect() --Disconnect all the touch events to make sure that the part hit only once.
							table.remove(touchEvents,i) --Remove them from the table so they dont get disconnected twice or else "Error".
						end
					end
				end)
				table.insert(touchEvents,touchev) --Adding the touch event to the table to disconnect it when the part is touched or the animation ends.
        	end
        end
		humanoid.WalkSpeed = 0 -- Set the walk speed to 0
		local kickAnimationTrack = PlayAnimation(kickAnimationId) -- Play the kick animation
		kickAnimationTrack.Stopped:Connect(function()
			pisarEnabled = false -- Disable stomping after the animation finishes
			humanoid.WalkSpeed = 16 -- Restore the default walk speed
			for i,v in ipairs(touchEvents) do
				v:Disconnect() --Disconnect all the touch events when the animation ends if the player did not hit any part.
			end
		end)
	end
end

-- Connect the toggle function to the C key input event
UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C then
		TogglePisar()
	end
end)

and I don’t why you are handling the touch from the client and the server at the same time, the script of Health Object only adds the missing Health values inside of the objects when you could just add the values by yourself take a rid of that script but here how it should be in case you really wanna use it.

local object = script.Parent
local health = object:FindFirstChild("Health")

if not health then
	health = Instance.new("IntValue")
	health.Name = "Health"
	health.Value = 1
	health.Parent = object
end

another last thing, you should have another script inside of ServerScriptService that will damage the part when DamageServer remote fired, It should be something like this:

local DamageServer =  game.ReplicatedStorage:WaitForChild("DamageServer")

damageAmount = 0.1 --Damage amount sould be on the server side to prevent cheaters from destroying your game and it should be a value smaller or equal to 1.
playersCooldown = {} --A cooldown table to prevent cheaters from spamming the remote.
cooldownDuration = 1 --Here the duration of the cooldown by seconds it depends on the duration of your animation.

local function TakeDamage(object)
	local health = part:FindFirstChild("Health")
	if health then
		health.Value = health.Value - damageAmount
		if health.Value <= 0 then
			object:Destroy()
		end
	end
end


DamageServer.OnServerEvent:Connect(function(player,part)
	if not table.find(playersCooldown,player) then --Check if the player in the cooldown list.
		TakeDamage(part) --Damaging the part.
		table.insert(playersCooldown,player) --Add the player to the cooldown list to prevent it from firing the remote again before the animation ends.
		wait(cooldownDuration) --Wait for the cooldown.
		--Remove the player from the cooldown list after the duration have passed.
		for i,plr in ipairs(playersCooldown) do
			if plr == player then
				table.remove(playersCooldown,i)
			end
		end
	end
end)

let me know if that worked for you.