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?
✓ ANSWER ACCEPTED
Is there a way to tell if an NPC has open dialogue?
1 answer
✓ Accepted answer
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.
1 comment
1
Thank you!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Are you using the Dialog objects that Roblox provides? I found on the api-reference on the wiki has a InUse property for them. You can use this to check when to stop the NPC through a loop if you wanted.
Yes, thank you!