Dialog

Show Deprecated

The Dialog object allows users to create non-player characters (NPCs) that players can talk to using a list of choices. The Dialog object can be inserted into a part such as a Humanoid's head, and then a player will see a speech bubble above the part that they can click on to start a conversation. The creator of a place can choose what choices the player can say by inserting DialogChoice objects into the dialog.

Summary

Properties

Sets whether the Dialog can be used by multiple players at once.

The furthest distance that I player can be from the Dialog's parent to start a conversation.

Toggles whether the goodbye option will be displayed.

Sets the sentence that the dialog will show to the player when the chat ends.

If true, this dialog is being used by at least one player.

Sets the first sentence that the dialog will show to the player, once a chat is commenced.

Sets the icon that the initial dialog displays.

Sets the color of the NPC's speech bubble.

Sets the maximum distance that a dialog can be triggered from.

Sets the offset of the dialog relative to the dialog's parent.

Methods


Returns a list of players currently using the Dialog.

Events


Fired when a player chooses something to say, through a Dialog instance.

Properties

BehaviorType

The BehaviorType of a Dialog determines whether multiple players can interact with a dialog at once. The default value for this property is SinglePlayer.

SinglePlayer

When a Dialog is configured to SinglePlayer, only one player can interact with it at a time. As soon as a player engages with a dialog, other players will not be able to initiate the dialog until the first player is finished.

While a player is engaged with a dialog, the other players will see the dialog choices of the player who started the dialog, along with the responses.

MultiplePlayers

When a Dialog is set to MultiplePlayers, any player can initiate a dialog at any time, even if another player has already initiated the dialog. Unlike SinglePlayer however, Dialogs set to MultiplePlayers will not show the dialog choices and responses to anyone but the player in the conversation.


local singlePlayerDialog = Instance.new("Dialog")
local singlePlayerPart = game.Workspace.SinglePlayerPart
singlePlayerDialog.BehaviorType = Enum.DialogBehaviorType.SinglePlayer
singlePlayerDialog.InitialPrompt = "Only one person can interact with me at once."
singlePlayerDialog.Parent = singlePlayerPart
local multiplePlayersDialog = Instance.new("Dialog")
local multiplePlayersPart = game.Workspace.MultiplePlayersPart
multiplePlayersDialog.BehaviorType = Enum.DialogBehaviorType.MultiplePlayers
multiplePlayersDialog.InitialPrompt = "Any number of players can interact with me at once."
multiplePlayersDialog.Parent = multiplePlayersPart

ConversationDistance

The furthest distance that I player can be from the Dialog's parent to start a conversation.

GoodbyeChoiceActive

Toggles whether the goodbye option will be displayed. If true, the dialog will display the content of Dialog.GoodbyeDialog as the last option after other dialog choices. Clicking on the goodbye option will exit the dialog.

GoodbyeChoiceActive = true

Active

GoodbyeChoiceActive = false

Inactive

GoodbyeDialog

Sets the sentence that the dialog will show to the player when the chat ends

InUse

If true, this dialog is being used by at least one player.

InitialPrompt

Sets the first sentence that the dialog will show to the player, once a chat is commenced.

Sets the icon that the initial dialog displays.

Sets the color of the NPC's speech bubble.

TriggerDistance

Sets the maximum distance that a dialog can be triggered from.

TriggerOffset

Sets the offset of the dialog relative to the dialog's parent.

Methods

GetCurrentPlayers

The GetCurrentPlayers function of a Dialog will return a list of Player currently using the Dialog. If there are no players using the dialog then the returned list will be empty.


Returns

Code Samples

Dialog:GetCurrentPlayers

local dialog = script.Parent
local function onChoiceSelected(_player, _choice)
local currentPlayers = dialog:GetCurrentPlayers()
print("The current players in the dialog:")
for _, player in ipairs(currentPlayers) do
print(player)
end
end
dialog.DialogChoiceSelected:Connect(onChoiceSelected)

Events

DialogChoiceSelected

Fired when a player chooses something to say, through a Dialog instance.

This event is client-side only and will not fire on the server. It should be connected to in either a LocalScript or a ModuleScript required by a LocalScript.

Parameters

player: Instance
dialogChoice: Instance