Dialogue Kit V2 // An easy way to create interactive Dialogues & Events

Instead you should execute the content number and not a reply. Lets say we have 3 pieces of content:

{“Content1”, “Content2”, “Content3”}

Everytime I separate text with a comma, thats the next piece of content which goes up by 1. You want to execute the code on the 3rd piece of content. So you set ExecuteContent to 3.

Alternatively, you can just set a reply button to nil and set the text to “Exit”.

I’ll have a look for it, but I’ll see if I can get it done in a patch.

1 Like

Tested it out, works very well and it’s very eye pleasing to be honest, and it isn’t hard to customize it by your needs!

1 Like

Dude. This is unbelievable. Fantastic work with this kit! The firing functions was an absolute no-brainer, I can’t explain how much fuss this has saved me! Well done and I’m looking forward for any future updates towards this system.

1 Like

So i tried to simplify this by putting scripts in each npc model which return the content table when it’s interact remotefunction is invoked but i have reaached a point where i want to use functions but dont know where to put them. did i just make my life harder?

heres the main localscript in the dialoguestorage

local Players = game:GetService("Players")
local DialoguesModule = require(script.Parent.Parent.Main:WaitForChild("DialoguesModule")) -- References the DialoguesModule to run DialoguesModule.CreateDialogue
local NPCs = workspace:WaitForChild("NPCs")
local lclPlayer = Players.LocalPlayer

for _, npc in pairs(NPCs:GetChildren()) do
	local canInteract = npc:FindFirstChild("Interact")
	if canInteract then
		local proximityPrompt = npc:WaitForChild("Torso"):WaitForChild("ProximityPrompt")
		proximityPrompt.Triggered:Connect(function()
			local interactFunc = npc:WaitForChild("Interact")
			local contentTable = interactFunc:InvokeServer(lclPlayer.leaderstats.Level.Value) -- Calls the interact function and stores the returned table in contentTable
			DialoguesModule.CreateDialogue(contentTable)
		end)
	end
end

and heres one of my npc scripts

local npc = script.Parent
local hum = npc:WaitForChild("Humanoid")

local idleAnim = Instance.new('Animation')
idleAnim.AnimationId = 'rbxassetid://86755365089343'
local idleAnimTrack = hum:LoadAnimation(idleAnim)
idleAnimTrack:Play()

local function GiveSpecial()
	print('function fired')
end

local interactFunc = npc:WaitForChild("Interact")
interactFunc.OnServerInvoke = function(player, level)
	local tableContent = {
		Content = {
			InitialLayer = "Layer1", -- Which layer to start the dialogue on
			DialogueTitle = npc.Name, -- The starting title of the Dialogue
			DialogueFrame = "DialogueFrame", -- Which DialogueFrame to use. Set to a custom one if you're using one. ("DialogueFrame" is the default.)
			ReplyFrame = "Reply", -- Which ReplyFrame to use if you're using a custom one. ("Reply" is the default.)

			Settings  = {
				Typewriter = true, -- Enable/Disable the typewriter. The typewriter writes every individual letter instead of displaying the text in full instantly.
				TypewriterSpeed = 0.01, -- How fast text is displayed on the typewriter.
				SpecialTypewriterSpeed = 0.5, -- How fast text is displayed for special characters. (. , ! ? ")
				TypewriterSound = "rbxassetid://9126065502", -- Sound to play each time a letter is wrote. Format as "rbxassetid://000" and not just a number.
				TypewriterSoundPitch = 1, -- Default is 1. TypewriterSoundRNGPitch must be disabled for this to work.
				TypewriterSoundRNGPitch = false, -- Set a random pitch between 0.8 and 1.2 each time a letter is wrote.

				Autoscroll = 0, -- 0 disables autoscroll. If the player doesn't click continue after the specified time, the dialogue moves to the next piece of content

				DialogueWalkSpeed = 0, -- The WalkSpeed when inside the dialogue. Set to nil to keep the defailt WalkSpeed.

				CinematicBars = false, -- Adds some cinematic bars when in the dialogue. Recommended if you're using the Cinematic skin.

				BackgroundSound = nil, -- Sound to play for the duration of the dialogue. Format as "rbxassetid://000" and not just a number.
				BackgroundSoundVol = 0.1, -- Volume of the BackgroundSound.

				DisableBackpack = true, -- Disables the players backpack when in the dialogue.
				DisableChat = false, -- Disables the chat when in the dialogue.
				DisableLeaderboard = false, -- Disables the leaderboard when in the dialogue.

				ContinueButtonVisibleDuringReply = false, -- Should the continue button be visible when replies are visible?
				ContinueButtonVisibleDuringTypewriter = false, -- Should the continue button be visible when the typewriter is writing?
				ContinueTextTransparency = 0.5, -- The transparency of the Continue text when the continue button is unable to be clicked.

				DialogueCam = nil, -- Set to a part instance and it will change the players camera to that part for the duration of the dialogue

				StopDialogueOnDeath = true, -- If the players humanoid dies, the dialogue will stop.
				InteractWithDialogueWhendead = false -- Can the player start the dialogue when they are dead?
			},

			Layer1 = { -- This is the first layer.
				DialogueContent = {"Greeting's young one. Sun's at its peak today.",}, -- This is what will be displayed on the Dialogue. Seperate content by commas.
				DialogueSounds = {}, -- Put in a SoundId to play per piece of content. If you don't want a sound for a piece of content then just set it as nil. Do not format as "rbxassetid://000" and just use the Soundid.
				DialogueImage = npc, -- This is the image that will be displayed, you can probably use it as an icon of your NPC. Not all Dialogue Skins support this.
				LayerTitle = nil, -- Set the text of your title again. This is the first layer so this isn't really needed, but you might want it for your 2nd layer.

				Replies = { -- This is a table of stuff the player can reply with to the Dialogue. They always appear at the last piece of content on the layer. ("Content2" in this case.)
					{
						ReplyName = "Where", -- This is the name of the reply button. It can be used to reference in Exec so you can run code when this button is clicked.
						ReplyText = "Where am I?", -- This is the text that will be displayed on your Reply Button.
						ReplyLayer = "Layer2" -- This is what Layer the player will be sent to if the player selects this reply.
					},

					{
						ReplyName = "Goodbye", -- This is the name of the reply button.
						ReplyText = "Goodbye!", -- This is the text that will be displayed on your Reply Button.
						ReplyLayer = nil -- Since the Layer is nil, the dialogue will just end as nil is not a layer and is nothing.
					}
				},

				Exec = { -- This is where you can run code in your dialogue if you want any custom functions. (Quests, Animations, etc.)
					--[[
					
					func1 = { 
						Function = customFunction1, -- Set this to a function you have created. Do not leave the brackets at the end.
						ExecuteContent = "_<\>continuebutton\\", -- Set to a number or the name of a Reply. If set to 1, it will execute at the first piece of content on the dialogue.
					},
					
					]]--
				}
			},

			Layer2 = { -- This is the second layer.
				DialogueContent = {"You are currently in Veletlen, and this is the Saogale Castle."}, -- This is your next piece of content if the player selects Reply1
				DialogueSounds = {},
				DialogueImage = npc, -- You can change the image to display here.
				LayerTitle = nil, -- You can change your Dialogue Title here. Keep as nil if you don't want it to change.

				Replies = {
					{
						ReplyName = "GiveMastery", -- This is the name of the reply button.
						ReplyText = "Mastery", -- This is the text that will be displayed on your Reply Button.
						ReplyLayer = "LayerMastery" -- Since the Layer is nil, the dialogue will just end as nil is not a layer and is nothing.
					},
					{
						ReplyName = "Goodbye", -- This is the name of the reply button.
						ReplyText = "Goodbye!", -- This is the text that will be displayed on your Reply Button.
						ReplyLayer = nil -- Since the Layer is nil, the dialogue will just end as nil is not a layer and is nothing.
					}
				},

				
			},

			LayerMastery = { -- Rename LayerName to the name of your layer. It can be whatever you want as long as it isnt the same as something else!
				DialogueContent = {"Sorry, you are not yet strong enough to handle the power of the flame. Come back when you have learnt the basics. (Lvl 15+) (Actually not implemented yet, WIP T-T)"},
				DialogueSounds = {},
				DialogueImage = npc,
				LayerTitle = nil,

				Replies = {
					{
						ReplyName = "Goodbye", -- This is the name of the reply button.
						ReplyText = "Goodbye!", -- This is the text that will be displayed on your Reply Button.
						ReplyLayer = nil -- Since the Layer is nil, the dialogue will just end as nil is not a layer and is nothing.
					}
				},
				
				Exec = {
					Special = { 
						Function = GiveSpecial, -- Set this to a function you have created. Do not leave the brackets at the end.
						ExecuteContent = 1, -- Set to a number or the name of a Reply. If set to 1, it will execute at the first piece of content on the dialogue.
					},
				}
			},

			--[[
			
			Use this to copy and paste a new layer if you want a clean layer.
			
			LayerName = { -- Rename LayerName to the name of your layer. It can be whatever you want as long as it isnt the same as something else!
				DialogueContent = {""},
				DialogueSounds = {},
				DialogueImage = "rbxassetid://000",
				LayerTitle = nil,

				Replies = {
				
				},

				Exec = {
				
				}
			},
			
			]]--
		},
	}
	return tableContent
end

My favourite dialogue kit and the only one I’m going to use, ever

Thanks! :slight_smile:

1 Like

I don’t understand what you’re trying to do, the NPC’s can have their own individual scripts like what you’re doing already inside the Dialogues ScreenGui.

I’d just use the system like this to do what you want to do instead of checking inside each NPC for when an event is fired.

1 Like

Hi, im trying to make it so when player selects Reply1 it runs a function which checks if the player meets certain conditions, and depending on how sucessful that function is it would change the reply of the npc, but I can’t seem to figure out how to do so.
Thanks for your time.

Hi! Sorry I’m a bit confused about the Cinematic option. How do I activate the skin? Or is it just CinematicBars = true?

You can use the cinematic bars setting with any skin, but they look the best with the cinematic skin. You need to define the Cinematic skin at the top of the dialogue.

Whats the name of it though? “CinematicSkin?”

If that’s the name of the frame, yes

1 Like

ive noticed a bug that is inconsistent and hard to replicate and im unsure if its my fault; basically, when chatting to the same npc more than twice, it occasionally does not bring the ui up. it seems to be replicated most easily by trying to talk to an npc very quickly. is this intended behavior, and if so am i expected to create my own debounce?

If you can reproduce the issue, message me a video and I’ll see what the problem is.