How to change NPC dialogue

Hello all! I’m trying to have one NPC’s dialogue change after interacting with another NPC. My issue is that the text that is supposed to appear after the player talks to one NPC doesn’t appear and instead the default text asking the player to talk to said NPC appears. (sorry if that is confusing haha). I’ve tried using bool values, variables, and even remote events to achieve this but they’ve all failed. How would I go about doing this? Am I making an error somewhere? I’m fairly new to scripting, and I am using Defaultio’s rich text markup.

Remote Event code

This is the code I tried using with remote events.

local gui = game.StarterGui.dialogueGUI
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TalkedTopainter = ReplicatedStorage:WaitForChild("TalkedTopainter")
-- click detectors
local skipper = game.Workspace.NPCs.skipper["skipper"].ClickDetector
local painter = game.Workspace.NPCs.Painter["Painter"].ClickDetector
-- code
skipper.MouseClick:Connect(function()
		local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
		script.Parent.Enabled = true
		local tweenService = game:GetService("TweenService")
		local dialogueFrame = script.Parent.Dialogue
		local textFrame = dialogueFrame.TextFrame
		local buttonA = dialogueFrame.Button
		dialogueFrame.Visible = false
		buttonA.Visible = false

		local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
		local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
		local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
		local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
		local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


		local function showButton()
			buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
			buttonA.Visible = true
			buttonFadeIn:Play()
			wait(buttonFadeIn.TweenInfo.Time)
		end

		local function clickButton()
			buttonClickTween:Play()
			wait(buttonClickTween.TweenInfo.Time)
			buttonFadeOut:Play()
			wait(buttonFadeOut.TweenInfo.Time)
			buttonA.Visible = false
		end

		local function showFrame()
			dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
			dialogueFrame.ImageTransparency = 1
			dialogueFrame.Visible = true
			frameFadeIn:Play()
			wait(frameFadeIn.TweenInfo.Time)
		end

		local function hideFrame()
			frameFadeOut:Play()
			wait(frameFadeOut.TweenInfo.Time)
			dialogueFrame.Visible = false
		end

		local function showDialogue(text, delayTime)
			local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
			textObject:Animate(true)
			showButton()
			wait(delayTime)
			clickButton()
			textObject:Hide()
		end




		local textSequence = {{Text = "Yo. I'm <Color=Red><AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2>Tyrone<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><Color=/>. I run things around here. Nice to meet you.", Delay = 1.7},
		{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You feel a bit nervous around the man's rather large arsenal of weapons.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
		{Text = "Don't worry about the guns. They're all <Color=Yellow>models<Color=/>.", Delay = 1.7},
		{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You breathe a sigh of relief.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
		{Text = "Y'know what? Meet me down in the<Color=Green><AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2> Town<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><Color=/>, I'll fill you in on whats going on.", Delay = 1.7},
		{Text = "Oh, and while you're here, could you do me a favor and talk to<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=25> the girl<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/> down there for me? I think she<AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2> really needs it.<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},


		}

		wait(1)

		showFrame()
		for _, v in pairs(textSequence) do
			showDialogue(v.Text, v.Delay)
		end
		hideFrame()
end)

game.ReplicatedStorage.TalkedTopainter.OnClientEvent:Connect(function() -- what I tried to do was wait until the TalkedTopainter event was fired
	local eventfired = Instance.new("BoolValue", workspace)
	eventfired.Name = "EventFired"
	repeat wait() until skipper.MouseClick:Connect()
	
		local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
		script.Parent.Enabled = true
		local tweenService = game:GetService("TweenService")
		local dialogueFrame = script.Parent.Dialogue
		local textFrame = dialogueFrame.TextFrame
		local buttonA = dialogueFrame.Button
		dialogueFrame.Visible = false
		buttonA.Visible = false

		local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
		local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
		local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
		local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
		local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


		local function showButton()
			buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
			buttonA.Visible = true
			buttonFadeIn:Play()
			wait(buttonFadeIn.TweenInfo.Time)
		end

		local function clickButton()
			buttonClickTween:Play()
			wait(buttonClickTween.TweenInfo.Time)
			buttonFadeOut:Play()
			wait(buttonFadeOut.TweenInfo.Time)
			buttonA.Visible = false
		end

		local function showFrame()
			dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
			dialogueFrame.ImageTransparency = 1
			dialogueFrame.Visible = true
			frameFadeIn:Play()
			wait(frameFadeIn.TweenInfo.Time)
		end

		local function hideFrame()
			frameFadeOut:Play()
			wait(frameFadeOut.TweenInfo.Time)
			dialogueFrame.Visible = false
		end

		local function showDialogue(text, delayTime)
			local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
			textObject:Animate(true)
			showButton()
			wait(delayTime)
			clickButton()
			textObject:Hide()
		end




		local textSequence = {{Text = "Thanks for talking to her.", Delay = 1.7},


		}

		wait(1)

		showFrame()
		for _, v in pairs(textSequence) do
			showDialogue(v.Text, v.Delay)
		end
		hideFrame()
	end)	

painter.MouseClick:Connect(function()
	TalkedTopainter:FireServer()
	local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
	script.Parent.Enabled = true
	local tweenService = game:GetService("TweenService")
	local dialogueFrame = script.Parent.Dialogue
	local textFrame = dialogueFrame.TextFrame
	local buttonA = dialogueFrame.Button
	dialogueFrame.Visible = false
	buttonA.Visible = false

	local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
	local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
	local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
	local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
	local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


	local function showButton()
		buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
		buttonA.Visible = true
		buttonFadeIn:Play()
		wait(buttonFadeIn.TweenInfo.Time)
	end

	local function clickButton()
		buttonClickTween:Play()
		wait(buttonClickTween.TweenInfo.Time)
		buttonFadeOut:Play()
		wait(buttonFadeOut.TweenInfo.Time)
		buttonA.Visible = false
	end

	local function showFrame()
		dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
		dialogueFrame.ImageTransparency = 1
		dialogueFrame.Visible = true
		frameFadeIn:Play()
		wait(frameFadeIn.TweenInfo.Time)
	end

	local function hideFrame()
		frameFadeOut:Play()
		wait(frameFadeOut.TweenInfo.Time)
		dialogueFrame.Visible = false
	end

	local function showDialogue(text, delayTime)
		local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
		textObject:Animate(true)
		showButton()
		wait(delayTime)
		clickButton()
		textObject:Hide()
	end




	local textSequence = {{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You approach the girl painting in the corner of the field.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*The second you step close to her, she whips her head to face you*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>HELLO!!!!<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You're caught off guard by the girl's outburst of energy.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=25>Hiya!!! I'm gonna be the greatest painter in the Dawn!<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2> *She yells out. The other people don't seem to mind.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She outstretches a paint stained hand. You take a deep breath and realize the air reeks of the smell of paint. You shake her hand begrudgingly.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Can I paint ya? Can I? Can I?<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She doesn't care about your response. She turns to remove the existing canvas and then back to you excitedly.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Awww... It seems I finally ran out of paint..<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Tell ya what, I'll meet you down at the town, and then I'll paint ya! <AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She turns back to the old canvas she was using.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},


	}

	wait(1)

	showFrame()
	for _, v in pairs(textSequence) do
		showDialogue(v.Text, v.Delay)
	end
	hideFrame()
end)
Bool Value code
local gui = game.StarterGui.dialogueGUI
local TalkedToPainter = game.StarterGui.dialogueGUI.TalkedToPainter
-- click detectors
local skipper = game.Workspace.NPCs.skipper["skipper"].ClickDetector
local painter = game.Workspace.NPCs.Painter["Painter"].ClickDetector
--bool value stuff
TalkedToPainter = false
--code
if TalkedToPainter == true then
	skipper.MouseClick:Connect()
	local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
	script.Parent.Enabled = true
	local tweenService = game:GetService("TweenService")
	local dialogueFrame = script.Parent.Dialogue
	local textFrame = dialogueFrame.TextFrame
	local buttonA = dialogueFrame.Button
	dialogueFrame.Visible = false
	buttonA.Visible = false

	local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
	local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
	local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
	local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
	local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


	local function showButton()
		buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
		buttonA.Visible = true
		buttonFadeIn:Play()
		wait(buttonFadeIn.TweenInfo.Time)
	end

	local function clickButton()
		buttonClickTween:Play()
		wait(buttonClickTween.TweenInfo.Time)
		buttonFadeOut:Play()
		wait(buttonFadeOut.TweenInfo.Time)
		buttonA.Visible = false
	end

	local function showFrame()
		dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
		dialogueFrame.ImageTransparency = 1
		dialogueFrame.Visible = true
		frameFadeIn:Play()
		wait(frameFadeIn.TweenInfo.Time)
	end

	local function hideFrame()
		frameFadeOut:Play()
		wait(frameFadeOut.TweenInfo.Time)
		dialogueFrame.Visible = false
	end

	local function showDialogue(text, delayTime)
		local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
		textObject:Animate(true)
		showButton()
		wait(delayTime)
		clickButton()
		textObject:Hide()
	end




	local textSequence = {{Text = "Thanks for talking to her.", Delay = 1.7},


	}

	wait(1)

	showFrame()
	for _, v in pairs(textSequence) do
		showDialogue(v.Text, v.Delay)
	end
	hideFrame()	
else
	skipper.MouseClick:Connect(function()
		local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
		script.Parent.Enabled = true
		local tweenService = game:GetService("TweenService")
		local dialogueFrame = script.Parent.Dialogue
		local textFrame = dialogueFrame.TextFrame
		local buttonA = dialogueFrame.Button
		dialogueFrame.Visible = false
		buttonA.Visible = false

		local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
		local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
		local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
		local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
		local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


		local function showButton()
			buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
			buttonA.Visible = true
			buttonFadeIn:Play()
			wait(buttonFadeIn.TweenInfo.Time)
		end

		local function clickButton()
			buttonClickTween:Play()
			wait(buttonClickTween.TweenInfo.Time)
			buttonFadeOut:Play()
			wait(buttonFadeOut.TweenInfo.Time)
			buttonA.Visible = false
		end

		local function showFrame()
			dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
			dialogueFrame.ImageTransparency = 1
			dialogueFrame.Visible = true
			frameFadeIn:Play()
			wait(frameFadeIn.TweenInfo.Time)
		end

		local function hideFrame()
			frameFadeOut:Play()
			wait(frameFadeOut.TweenInfo.Time)
			dialogueFrame.Visible = false
		end

		local function showDialogue(text, delayTime)
			local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
			textObject:Animate(true)
			showButton()
			wait(delayTime)
			clickButton()
			textObject:Hide()
		end




		local textSequence = {{Text = "Yo. I'm <Color=Red><AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2>Tyrone<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><Color=/>. I run things around here. Nice to meet you.", Delay = 1.7},
		{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You feel a bit nervous around the man's rather large arsenal of weapons.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
		{Text = "Don't worry about the guns. They're all <Color=Yellow>models<Color=/>.", Delay = 1.7},
		{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You breathe a sigh of relief.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
		{Text = "Y'know what? Meet me down in the<Color=Green><AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2> Town<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><Color=/>, I'll fill you in on whats going on.", Delay = 1.7},
		{Text = "Oh, and while you're here, could you do me a favor and talk to<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=25> the girl<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/> down there for me? I think she<AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2> really needs it.<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},


		}

		wait(1)

		showFrame()
		for _, v in pairs(textSequence) do
			showDialogue(v.Text, v.Delay)
		end
		hideFrame()
	end)
end

painter.MouseClick:Connect(function()
	TalkedToPainter = true
	local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
	script.Parent.Enabled = true
	local tweenService = game:GetService("TweenService")
	local dialogueFrame = script.Parent.Dialogue
	local textFrame = dialogueFrame.TextFrame
	local buttonA = dialogueFrame.Button
	dialogueFrame.Visible = false
	buttonA.Visible = false

	local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
	local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
	local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
	local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
	local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


	local function showButton()
		buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
		buttonA.Visible = true
		buttonFadeIn:Play()
		wait(buttonFadeIn.TweenInfo.Time)
	end

	local function clickButton()
		buttonClickTween:Play()
		wait(buttonClickTween.TweenInfo.Time)
		buttonFadeOut:Play()
		wait(buttonFadeOut.TweenInfo.Time)
		buttonA.Visible = false
	end

	local function showFrame()
		dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
		dialogueFrame.ImageTransparency = 1
		dialogueFrame.Visible = true
		frameFadeIn:Play()
		wait(frameFadeIn.TweenInfo.Time)
	end

	local function hideFrame()
		frameFadeOut:Play()
		wait(frameFadeOut.TweenInfo.Time)
		dialogueFrame.Visible = false
	end

	local function showDialogue(text, delayTime)
		local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
		textObject:Animate(true)
		showButton()
		wait(delayTime)
		clickButton()
		textObject:Hide()
	end




	local textSequence = {{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You approach the girl painting in the corner of the field.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*The second you step close to her, she whips her head to face you*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>HELLO!!!!<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You're caught off guard by the girl's outburst of energy.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=25>Hiya!!! I'm gonna be the greatest painter in the Dawn!<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2> *She yells out. The other people don't seem to mind.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She outstretches a paint stained hand. You take a deep breath and realize the air reeks of the smell of paint. You shake her hand begrudgingly.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Can I paint ya? Can I? Can I?<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She doesn't care about your response. She turns to remove the existing canvas and then back to you excitedly.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Awww... It seems I finally ran out of paint..<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Tell ya what, I'll meet you down at the town, and then I'll paint ya! <AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She turns back to the old canvas she was using.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},


	}

	wait(1)

	showFrame()
	for _, v in pairs(textSequence) do
		showDialogue(v.Text, v.Delay)
	end
	hideFrame()
end)
Variable code
local gui = game.StarterGui.dialogueGUI
local TalkedToPainter = 0
-- click detectors
local skipper = game.Workspace.NPCs.skipper["skipper"].ClickDetector
local painter = game.Workspace.NPCs.Painter["Painter"].ClickDetector
--code
if TalkedToPainter == 1 then
	skipper.MouseClick:Connect()
	local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
	script.Parent.Enabled = true
	local tweenService = game:GetService("TweenService")
	local dialogueFrame = script.Parent.Dialogue
	local textFrame = dialogueFrame.TextFrame
	local buttonA = dialogueFrame.Button
	dialogueFrame.Visible = false
	buttonA.Visible = false

	local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
	local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
	local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
	local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
	local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


	local function showButton()
		buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
		buttonA.Visible = true
		buttonFadeIn:Play()
		wait(buttonFadeIn.TweenInfo.Time)
	end

	local function clickButton()
		buttonClickTween:Play()
		wait(buttonClickTween.TweenInfo.Time)
		buttonFadeOut:Play()
		wait(buttonFadeOut.TweenInfo.Time)
		buttonA.Visible = false
	end

	local function showFrame()
		dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
		dialogueFrame.ImageTransparency = 1
		dialogueFrame.Visible = true
		frameFadeIn:Play()
		wait(frameFadeIn.TweenInfo.Time)
	end

	local function hideFrame()
		frameFadeOut:Play()
		wait(frameFadeOut.TweenInfo.Time)
		dialogueFrame.Visible = false
	end

	local function showDialogue(text, delayTime)
		local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
		textObject:Animate(true)
		showButton()
		wait(delayTime)
		clickButton()
		textObject:Hide()
	end




	local textSequence = {{Text = "Thanks for talking to her.", Delay = 1.7},


	}

	wait(1)

	showFrame()
	for _, v in pairs(textSequence) do
		showDialogue(v.Text, v.Delay)
	end
	hideFrame()	
else
	skipper.MouseClick:Connect(function()
		local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
		script.Parent.Enabled = true
		local tweenService = game:GetService("TweenService")
		local dialogueFrame = script.Parent.Dialogue
		local textFrame = dialogueFrame.TextFrame
		local buttonA = dialogueFrame.Button
		dialogueFrame.Visible = false
		buttonA.Visible = false

		local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
		local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
		local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
		local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
		local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


		local function showButton()
			buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
			buttonA.Visible = true
			buttonFadeIn:Play()
			wait(buttonFadeIn.TweenInfo.Time)
		end

		local function clickButton()
			buttonClickTween:Play()
			wait(buttonClickTween.TweenInfo.Time)
			buttonFadeOut:Play()
			wait(buttonFadeOut.TweenInfo.Time)
			buttonA.Visible = false
		end

		local function showFrame()
			dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
			dialogueFrame.ImageTransparency = 1
			dialogueFrame.Visible = true
			frameFadeIn:Play()
			wait(frameFadeIn.TweenInfo.Time)
		end

		local function hideFrame()
			frameFadeOut:Play()
			wait(frameFadeOut.TweenInfo.Time)
			dialogueFrame.Visible = false
		end

		local function showDialogue(text, delayTime)
			local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
			textObject:Animate(true)
			showButton()
			wait(delayTime)
			clickButton()
			textObject:Hide()
		end




		local textSequence = {{Text = "Yo. I'm <Color=Red><AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2>Tyrone<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><Color=/>. I run things around here. Nice to meet you.", Delay = 1.7},
		{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You feel a bit nervous around the man's rather large arsenal of weapons.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
		{Text = "Don't worry about the guns. They're all <Color=Yellow>models<Color=/>.", Delay = 1.7},
		{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You breathe a sigh of relief.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
		{Text = "Y'know what? Meet me down in the<Color=Green><AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2> Town<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><Color=/>, I'll fill you in on whats going on.", Delay = 1.7},
		{Text = "Oh, and while you're here, could you do me a favor and talk to<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=25> the girl<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/> down there for me? I think she<AnimateStyle=Wiggle><AnimateStepFrequency=1><AnimateStyleTime=2> really needs it.<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},


		}

		wait(1)

		showFrame()
		for _, v in pairs(textSequence) do
			showDialogue(v.Text, v.Delay)
		end
		hideFrame()
	end)
end

painter.MouseClick:Connect(function()
	TalkedToPainter = 1
	local richText = require(script.Parent:FindFirstChild("RichText") or script.Parent.Parent)
	script.Parent.Enabled = true
	local tweenService = game:GetService("TweenService")
	local dialogueFrame = script.Parent.Dialogue
	local textFrame = dialogueFrame.TextFrame
	local buttonA = dialogueFrame.Button
	dialogueFrame.Visible = false
	buttonA.Visible = false

	local buttonFadeIn = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 0})
	local buttonFadeOut = tweenService:Create(buttonA, TweenInfo.new(0.1), {ImageTransparency = 1})
	local buttonClickTween = tweenService:Create(buttonA, TweenInfo.new(0.05, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.25, 0, 0.25, 0)})
	local frameFadeIn = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {Size = dialogueFrame.Size, ImageTransparency = 0})
	local frameFadeOut = tweenService:Create(dialogueFrame, TweenInfo.new(0.4), {ImageTransparency = 1})


	local function showButton()
		buttonA.Size = UDim2.new(0.3, 0, 0.3, 0)
		buttonA.Visible = true
		buttonFadeIn:Play()
		wait(buttonFadeIn.TweenInfo.Time)
	end

	local function clickButton()
		buttonClickTween:Play()
		wait(buttonClickTween.TweenInfo.Time)
		buttonFadeOut:Play()
		wait(buttonFadeOut.TweenInfo.Time)
		buttonA.Visible = false
	end

	local function showFrame()
		dialogueFrame.Size = UDim2.new(0.4, 0, 0.1, 0)
		dialogueFrame.ImageTransparency = 1
		dialogueFrame.Visible = true
		frameFadeIn:Play()
		wait(frameFadeIn.TweenInfo.Time)
	end

	local function hideFrame()
		frameFadeOut:Play()
		wait(frameFadeOut.TweenInfo.Time)
		dialogueFrame.Visible = false
	end

	local function showDialogue(text, delayTime)
		local textObject = richText:New(textFrame, text, {Font = "Cartoon"})
		textObject:Animate(true)
		showButton()
		wait(delayTime)
		clickButton()
		textObject:Hide()
	end




	local textSequence = {{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You approach the girl painting in the corner of the field.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*The second you step close to her, she whips her head to face you*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>HELLO!!!!<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*You're caught off guard by the girl's outburst of energy.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=25>Hiya!!! I'm gonna be the greatest painter in the Dawn!<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/><AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2> *She yells out. The other people don't seem to mind.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She outstretches a paint stained hand. You take a deep breath and realize the air reeks of the smell of paint. You shake her hand begrudgingly.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Can I paint ya? Can I? Can I?<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She doesn't care about your response. She turns to remove the existing canvas and then back to you excitedly.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Awww... It seems I finally ran out of paint..<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Rainbow><AnimateStepFrequency=1><AnimateStyleTime=5>Tell ya what, I'll meet you down at the town, and then I'll paint ya! <AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},
	{Text = "<AnimateStyle=Fade><AnimateStepFrequency=1><AnimateStyleTime=2>*She turns back to the old canvas she was using.*<AnimateStyle=/><AnimateStepFrequency=/><AnimateStyleTime=/>", Delay = 1.7},


	}

	wait(1)

	showFrame()
	for _, v in pairs(textSequence) do
		showDialogue(v.Text, v.Delay)
	end
	hideFrame()
end)

Any help is really appreciated and sorry if the code is a bit long to look through.