I have created a Soldier-AI, and i want to improve it

I have created a Soldier AI from scratch using other AI codes, it’s function is to find an enemy, as any other AI, except that if there’s no AI, it will check if there’s a statue, and walk to it and shoot it, like Guest Defense, however, i’m no satisfied with the code, i know it requires alot of optimization and other stuff, but i don’t have more options to replace those lines. I want to say some stuff first: The code include two tables, both are used to store names for allies, but both tables have different functions, the first table is used to check the characters/npc names that cannot be shot, and the second table is to store the first table and the statue names, used so the AIs can’t walk to the statues and check them like normal targets. The other thing i want to mention is that in the second table you will find the strings “Map” which is the map of the game, and “IdiotStatue”, which is the statue, the other thing i want to say is that the AI have different path and check target functions for normal targets (NPC or players) and the statue.

The code is very long, so if you need to me to explain you something, you can ask me.

In conclusion, i want to improve my Soldier-AI, here is the soldier (You can use it in your games):
SoldierStages.rbxm (27.5 KB)
I would be really happy if someone would help me. Thanks for reading.

6 Likes