Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there a way to tell if an NPC has open dialogue?

Asked by 4 years ago

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?

0
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. xPolarium 1388 — 4y
0
Yes, thank you! OswinFalls 69 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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
Thank you! OswinFalls 69 — 4y
Ad

Answer this question