Getting Register NPC name

Hello,

i’m having trouble in finding a way to know which registered NPC i’m talking with. (Registered in table)

Let me explain;

I use some NPC on my server, these NPC are registered like : NPC 1 / NPC 2 / NPC 3…

Which code should i use to know that i’m talking with NPC 1 for exemple ?

I hope you understood what i just said, not easy to explain in english.

Cycle through all the NPCs using a for-loop and if you found a match return it.



local t = {"npc2","npc100","npc341","npc231"}
for id, npc in pairs(t)do
if ( npc == "npc100" ) then
-- This is our NPC, do something here
end
end