How do I run a function with the same name as a part/model

So I’m trying to write code for enemies in my game all in one script using functions (running a function per enemy). Right now I’m using if statements by detecting what the enemy’s name is and running the corresponding function manually. Instead of putting an if statement for every enemy in the game to run the right function, I instead want to run the function that has the same name as the enemy, but I don’t know how to.

I’ve tried something like task.spawn(EnemyName) or task.spawn([EnemyName]), but nothing worked. I couldn’t find an answer to this so I’m posting here.

Hi! There is an example:

local SomeTable = {
	["Some Name"] = function()
		print('e')
	end,
}

SomeTable["Some Name"]()

How could I go about actually using this? Another example would be nice of it being used. Thanks!

local Enemy = workspace.Zombie
local EnemyName = Enemy.Name -- Zombie
local functions = {
	["Zombie"] = function(Enemy:Model)
		Enemy:FindFirstChildOfClass("Humanoid").Health = 0
	end,
}

task.wait(1)

functions[EnemyName](Enemy)