Hey all, I've done some searching and I apologize if the answer to this already exists (it probably does) and I just missed it. But I'm trying to start off my project with a friendly NPC that would come up to the player, open a gate, speak to them, then run back to their starting location in a building and remain there. The intent is that the player, based on what they've been told, will go out and pick up a weapon at which point the NPC will die and two enemies will spawn (and a gunshot sound will play, hopefully prompting the player to head back to the NPC). Now I think I can manage the NPC dieing, enemies spawning, and gun shot sound just fine. I'm also sure I can handle the gate opening and NPC talking, but I'm not sure how to make the NPC follow the waypoint to the player, freeze in place, then head back and remain in place at their original starting location with new speech text. I can get them to follow a waypoint based on the soldier script but how I can get them to only do it once, and how can I make them move without looking they're trying to hold a gun up?
My plan is to kick this off with a trigger zone the player enters. Off the top of my head I feel like it should just be a matter of setting a variable once the player enters the zone that causes the NPC to move (their patrol route starting only once the variable is met) then resetting that variable once the move + talk + move back is complete, but I'm new to lua scripting (and haven't really touched programming in general in close to a decade) and can't figure out how to get the waypoint following from existing scripts and apply that to my custom NPC.