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.