Cafe NPC Customers!

Hello! I am new to scripting, and I know very little. I was wondering how I could go about making NPC Customers for my cafe that would go up to baristas, and once the barista states their greeting, the NPC orders a few random items. I was the NPCs to be able to receive the items, so like a proximity prompt that says hand items, and once you hold it then it will give the items to them and the NPC will walk away. Can anyone explain how to go about doing this? I’m only a beginner, so I don’t know much. Anything helps! Thanks!

2 Likes

This is a pretty intricate system and requires many different things however it is possible.

  • You’d need a method for detecting if someone is at a register, as it’d be kinda weird if your NPCs just went up to vacant registers. A couple ideas would be to check if the register is claimed by someone (if you have a claiming register system of course), or looping through each barista and checking if they are close to a register possibly.

  • For the NPC itself you could use a simple approach of simply cloning pre-made NPCs from somewhere like ServerStorage, or apply HumanoidDescriptions to an NPC template and clone it into workspace. Once you do that you can use PathfindingService or Humanoid:MoveTo() to make the NPC move to the players general area

  • You’ll need to wait for the barista to say something, you can create a Player.Chatted event connection on the specific barista and then disconnect it after it’s been fired once (or use :Once), then have the NPC say something with :Chat. You could keep a table or something of all the menu items and then use math.random() to get some random menu items from the table.

  • ProximityPrompts use .Triggered, so you can detect whenever that’s fired and use the first parameter of that event to determine if the barista is the one who triggered the ProximityPrompt, if so you can destroy the NPC once the items or given.

Overall this is quite an oversimplified explanation but I hope this puts you on the right track.

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.