I'd like to have an NPC walking around, but if a player opens a dialogue with them, they would stop moving, and resuming walking when they are no longer talking to a player. Is there a variable or way I can find out whether or not they are in an open chat?
There is a property in the Dialog
object called Dialog.InUse
. This is true when the dialog is being used and false when it is not. If you do something like this:
-- Make sure there is a variable called dialog referenced to your dialog object dialog:GetPropertyChangedSignal("InUse"):Connect(function() if dialog.InUse then -- Have code for stopping the NPC here elseif not dialog.InUse then -- Have code for the NPC to continue walking here end end)
then it should work!
Basically, we use Instance:GetPropertyChangedSignal(string Property)
to get an event that fires when the Dialog.InUse
property changes. We then check what the value of Dialog.InUse
is and we can then stop or continue the NPC.