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.
The furthest distance that I player can be from the Dialog's parent to start a conversation.
Sets the first sentence that the dialog will show to the player, once a chat is commenced.
The BehaviorType of a Dialog determines whether multiple players can interact with a dialog at once. The default value for this property is 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.
When a Dialog is setto 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.
1local singlePlayerDialog = Instance.new("Dialog")2local singlePlayerPart = game.Workspace.SinglePlayerPart3singlePlayerDialog.BehaviorType = Enum.DialogBehaviorType.SinglePlayer4singlePlayerDialog.InitialPrompt = "Only one person can interact with me at once."5singlePlayerDialog.Parent = singlePlayerPart67local multiplePlayersDialog = Instance.new("Dialog")8local multiplePlayersPart = game.Workspace.MultiplePlayersPart9multiplePlayersDialog.BehaviorType = Enum.DialogBehaviorType.MultiplePlayers10multiplePlayersDialog.InitialPrompt = "Any number of players can interact with me at once."11multiplePlayersDialog.Parent = multiplePlayersPart12
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.
1local dialog = script.Parent23local function onChoiceSelected(_player, _choice)4 local currentPlayers = dialog:GetCurrentPlayers()5 print("The current players in the dialog:")6 for _, player in ipairs(currentPlayers) do7 print(player)8 end9end1011dialog.DialogChoiceSelected:Connect(onChoiceSelected)