Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What should I use for this?

I'm trying to create an NPC that shoots at other NPC's but I haven't found a way to actually find the other NPC's. I thought of using a Module Script to find the NPC's that were out and see if their position was close enough to the starting one, but it seems I can only use it once. I'm new to LUA and I'm unsure what I should use for this? I don't want the full out script, just what action/event I can use to call to find the nearest NPC. In advance, thanks for any help.

1 answer

✓ Accepted answer

Well, it seems that you are asking for a nearest distance method. If that is the case, what you should do is:

Calculate distance between them by using

(searcherNPC.Torso.Position - otherNPC.Torso.Position).magnitude

I hope this helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.