Help with custom dialogue options system

Hullo, I want to get a fully functional dialogue system into my game, yet i’ve run into a roadblock…

image
This is supposed to be going up smoothly in 1s from -1 all the way up to a custom value…
Here is a gif of what happens:
https://gyazo.com/301aa6538ab7350c47d9e59c640bfd18
the problem is that the npc dialogue doesn’t change at all, yet somehow the text on the text button does change, it’s really weird.
Script:

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local createDialogueEvent = ReplicatedStorage.Remotes.createDialogueEvent
local hideDialogueEvent = ReplicatedStorage.Remotes.hideDialogueEvent
local setDialogueImageEvent = ReplicatedStorage.Remotes.setDialogueImageEvent
local DialogueOptionsEvent = ReplicatedStorage.Remotes.DialogueOptionsEvent
local interaction = -1

workspace.TalkGuardEvent.ProximityPrompt.Triggered:Connect(function(plr)
	setDialogueImageEvent:FireClient(plr,workspace.Guard.Name,Color3.fromRGB(255, 255, 255))
	createDialogueEvent:FireClient(plr,'Hullo')	
	DialogueOptionsEvent:FireClient(plr,1,true,'pick me or else',nil,'Sorry, I don\'t have time at the moment..','Guard',interaction)
end)

DialogueOptionsEvent.OnServerEvent:Connect(function(plr,optionchosen,str,interaction,talkdb)
	if talkdb == false then
	if str == 'Guard' then
		if optionchosen == 'Option1' then
				if interaction == 0 then
				setDialogueImageEvent:FireClient(plr,workspace.Guard.Name,Color3.fromRGB(255, 255, 255))
				createDialogueEvent:FireClient(plr,'oh so you\'ve chosen option 1?')	
				DialogueOptionsEvent:FireClient(plr,1,true,'aeagfgdfgdfgh',nil,'Sorry, I don\'t have time at the moment..','Guard',interaction)
				elseif interaction == 1 then
				setDialogueImageEvent:FireClient(plr,workspace.Guard.Name,Color3.fromRGB(255, 255, 255))
			createDialogueEvent:FireClient(plr,'ah yes, number 2')	
				DialogueOptionsEvent:FireClient(plr,1,true,'ok',nil,'Sorry, I don\'t have time at the moment..','Guard',interaction)
			elseif interaction == 2 then
				setDialogueImageEvent:FireClient(plr,workspace.Guard.Name,Color3.fromRGB(255, 255, 255))
				createDialogueEvent:FireClient(plr,'congrats you made it to the 3rd interaction with me')	
				DialogueOptionsEvent:FireClient(plr,1,true,'nil button, me when',nil,'Sorry, I don\'t have time at the moment..','Guard',interaction)
			end
		end
		end
		end
end)

and here is my local script

local StarterGui = game:GetService("StarterGui")

local createDialogueEvent = game.ReplicatedStorage.Remotes.createDialogueEvent
local hideDialogueEvent = game.ReplicatedStorage.Remotes.hideDialogueEvent
local setDialogueImageEvent = game.ReplicatedStorage.Remotes.setDialogueImageEvent
local DialogueOptionsEvent = game:GetService('ReplicatedStorage').Remotes.DialogueOptionsEvent

local richText = require(game.ReplicatedStorage.Modules.RichText)

local player = game.Players.LocalPlayer
local dialogueFrame = player.PlayerGui.MainGui.DialogueFrame

local function swooshSound()
	local sound = Instance.new("Sound",game.ReplicatedStorage)
	sound.PlaybackSpeed = 1
	sound.Volume = 1
	sound.PlayOnRemove = true
	sound.SoundId = "rbxassetid://4845387138"
	sound:Destroy()
end

hideDialogueEvent.OnClientEvent:Connect(function()
	
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	
	swooshSound()
	dialogueFrame:TweenPosition(UDim2.new(0.5,0,2,0),.1)
end)

createDialogueEvent.OnClientEvent:Connect(function(english,spanish)
	if dialogueFrame.Position ~= UDim2.new(0.5,0,0.85,0) then
		
		StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		
		dialogueFrame:TweenPosition(UDim2.new(0.5,0,0.85,0),.1)
		
	end
	
	local ln = game:GetService("LocalizationService").RobloxLocaleId
	local content = english
	if ln == "en-us" then
		content = english
	elseif ln == "es-es" then
		if spanish then
			content = spanish
		end
	end
	
	local textObject = richText:New(dialogueFrame.textFrame, content)
	textObject:Animate(true)
end)

-- Viewport Script Starts Here

local function cleanVPF()

	if dialogueFrame.ViewportFrame:FindFirstChildOfClass("Model") then
		dialogueFrame.ViewportFrame:FindFirstChildOfClass("Model"):Destroy()
	end

	if dialogueFrame.ViewportFrame:FindFirstChildOfClass("Camera") then
		dialogueFrame.ViewportFrame:FindFirstChildOfClass("Camera"):Destroy()
	end

end

setDialogueImageEvent.OnClientEvent:Connect(function(charName,color)
	dialogueFrame.nameLabel.TextColor3 = color
	dialogueFrame.nameLabel.Text = charName

	local vpCharacter = game.Workspace:FindFirstChild(charName)
	if vpCharacter then
		
		cleanVPF()
		
		local obj = vpCharacter:Clone()
		obj.Parent = dialogueFrame.ViewportFrame
		
		local cam = Instance.new("Camera")
		cam.Parent = dialogueFrame.ViewportFrame
		
		cam.CFrame = CFrame.new(obj.Head.Position + (obj.PrimaryPart.CFrame.lookVector*2), obj.Head.Position)
		
		dialogueFrame.ViewportFrame.CurrentCamera = cam
		
	else
		warn(charName .. " is not in ReplicatedStorage")
	end
	
end)

--stuff above here is a free script from https://www.youtube.com/watch?v=ZHABEzphzWk--

local talkdb = false

DialogueOptionsEvent.OnClientEvent:Connect(function(amountOfOptions,option3exit,option1text,option2text,option3text,identifier,interaction)
	if talkdb == false then
		talkdb = true
	if amountOfOptions == 1 then
		dialogueFrame.Option1.Visible = true
		dialogueFrame.Option1.Text = option1text
			dialogueFrame.Option1.MouseButton1Click:Connect(function()
					DialogueOptionsEvent:FireServer('Option1',identifier,interaction+1,talkdb)
			print(interaction)
		end)
	elseif amountOfOptions == 2 then
		dialogueFrame.Option1.Visible = true
		dialogueFrame.Option1.Text = option1text
		dialogueFrame.Option2.Visible = true
		dialogueFrame.Option2.Text = option2text
		DialogueOptionsEvent:FireServer('Option2',identifier,interaction)
	elseif amountOfOptions == 3 then
		dialogueFrame.Option1.Visible = true
		dialogueFrame.Option1.Text = option1text
		dialogueFrame.Option2.Visible = true
		dialogueFrame.Option2.Text = option2text
		dialogueFrame.Option3.Visible = true
		dialogueFrame.Option3.Text = option3text
		DialogueOptionsEvent:FireServer('Option3',identifier,interaction)
	end
	if option3exit == true then
		dialogueFrame.Option3.Visible = true
		dialogueFrame.Option3.Text = option3text
		dialogueFrame.Option3.MouseButton1Click:Connect(function()
			StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

			swooshSound()
			dialogueFrame:TweenPosition(UDim2.new(0.5,0,2,0),.1)
		end)
		end
		task.wait(0.2)
		talkdb = false
		end
end)

Boy, solutions? I did a lot of things, such as messing around with the interaction variable, changing values, making new variables, making debounces and more, please, I desperately need help.

man this post is 5 days old and I haven’t had a single reply

Hello, I will put the scripts in studio so they’re readable and I’ll see what I can do to make it better for you!

This took a lot of effort to recreate.
I found that changing lines 96-99 in the local script helps with this.

			dialogueFrame.Option1.MouseButton1Click:Connect(function()
				DialogueOptionsEvent:FireServer('Option1',identifier,interaction,talkdb)
				interaction += 1
				print(interaction)
			end)

The new problem is that it isn’t limited and it continues to go up beyond the 3 interaction limit.

1 Like

Oh god, I should’ve included a copy of the game instead of just saying the script, I am sorry about that. It works and I am very glad for it, the interaction limit isn’t quite as relevant as the final message just repeats itself, I cannot thank you enough for this, I’ve been waiting 5 days for an answer and this is amazing, once again, thank you.

1 Like