NPC Dialog Guide

From Legacy Roblox Wiki
Jump to navigationJump to search

Making that chat bubble

Select the part you want to talk in the explorer then insert a dialog into the part. Insert>Object>Dialog

Dialog properties: ConversationDistance - how close you have to be to talk. Measured in studs. InUse - true if NPC (non player character) is being talked to. InitialPrompt - what the NPC first says when a player starts chatting to it. Purpose - sets the icon in the dialog when NPC isn't chatting. Tone - sets the color of the dialog

The rest are just global properties. Eg. Name, Parent, className...

Choices!

If we just put a dialog that says one thing when you chat to it it wouldn't be that great. Why not make it more exciting by respond to what it says with a few options to choose from!

I will be introducing another instance type called DialogChoice.


Select the dialog and insert a DialogChoice instance. Insert>Object>DialogChoice

DialogChoice properties: ResponseDialog - what the NPC says in reply to what the choice is. UserDialog - the choice you see near the bottom-left of your screen.

The rest are global properties.

You can put more than 1 choice/reply within a dialog. And make choices inside choices!!! 1 last thing before I make a dialog shop example. There is a special event for Dialog. It's .DialogChoiceSelected. It triggers when you click a choice. It's useful for quests and shops.

Shop Example

Structure of the game:
game

Workspace
-Base - Part
-Part - Part
--Dialog - Dialog
---Script - Script
---Weapons - DialogChoice
----Sword - DialogChoice
Lighting
--Sword - Tool


tool = game.Lighting.Sword:Clone() -- sword tool 

function onDialogChoiceSelected(player, DialogChoice) --triggers when someone chooses a choice 
if (DialogChoice.Name == "Sword") then -- if they chose the sword then...
tool:Clone().Parent = player.Backpack --it gives them a sword
end 
end 

script.Parent.DialogChoiceSelected:connect(onDialogChoiceSelected) --connection line

Dialog shop example: http://www.roblox.com/Dialog-Shop-Demo-item?id=41450002