Collisions triggering animations

I’m trying to make a simple system where when the sword touches “Enemy” the enemy sends a message to “Enemy Heath Bar” which then plays an animation based on the state of the current “Enemy_Heath”, but it doesn’t work. Btw I did get collision messages from the consol prior to adding the messaging code.

The Enemy Heath Bar code:

Enemy_Heath = 2

function on_message(self, message_id, message)
	if message_id == "Damage" and Enemy_Heath == 2 then
		sprite.play_flipbook("/Enemy Heath Bar", ("Enemy Heath Bar 1"))
		Enemy_Heath = 1
	else if message_id == "Damage" and Enemy_Heath == 1 then
		sprite.play_flipbook("/Enemy Heath Bar", ("Enemy Heath Bar 2"))
		Enemy_Heath = 0
	end

The Enemy Code:

function on_message(self, message_id, message, sender)
	if(message_id == hash("contact_point_response"))
	and message.other_group == hash("Sword") then
		msg.post("/Enemy Heath Bar", "Damage")
	end
end

No one responded within a day so I figured it out myself.

What was the problem?

Heath? You mean Health?

I said “but it doesn’t work” and in my game, “health” is spelled “heath”

We ask “what was the problem” so that future users may read this and see what the issue was in case they face a similar issue.