How to switch from NPC to Player's Name back and forth

Hello! I’m having trouble changing the name label of the NPC to player’s name in a dialog system. Here are the codes:

Module code inside the NPC:

local Chats = {
	
	{Text = "...",	
		NPC = true,
		Question = true,
		Option1 = {"Why are you crying?", "I've lost my power core"},
		Option2 = {"Weird..", "Why "}
	},
	
	{Text = "Lol",
		Player = true
	},
	
	{Text = "Do you think I should go on walks more often?",
		NPC = true,
		Question = true,
		Option1 = {"Yes", "Ah fine, I guess I should."},
		Option2 = {"No", "Yeah okay, thank you."}
	}
}

return Chats

Local Script inside GUI:

local mouse = game.Players.LocalPlayer:GetMouse()
local chatting = Instance.new("BoolValue", game.Players.LocalPlayer)
local ChattingGUI =	game.Players.LocalPlayer.PlayerGui:WaitForChild("NPCChat") 
chatting.Name = "Chatting"

local function settext(sentence)
	local textlabel = game.Players.LocalPlayer.PlayerGui.NPCChat.NPCText
	textlabel.Text = ""
	for i = 1, string.len(sentence) do wait(0.025)
		textlabel.Text = string.sub(sentence, 1, i)
	end
end

for i, v in pairs(game.Workspace:WaitForChild("NPCs"):GetChildren()) do
	local humanoidRootPart = v:WaitForChild("HumanoidRootPart")
	local Prompt = humanoidRootPart:WaitForChild("PromptAttachment"):WaitForChild("ProximityPrompt")
print("pass 1")
	Prompt.ActionText = "Chat with "..v.Name
	print("pass 2")
	Prompt.ObjectText = v.Name
	print("pass 3")
	
	Prompt.Triggered:Connect(function(plr)
		
		if chatting.Value == false then chatting.Value = true
			local int = 1
			local chatsTable = require(v.Chats)
			local writing = false
			local yesConnection
			local noConnection
			local mouseConnection
			ChattingGUI.NPCText.Text = ""
			ChattingGUI.NameLabel.NPCName.Text = v.Name
			plr.PlayerGui.NPCChat.Enabled = true
			Prompt.Enabled = false
			settext(chatsTable[1].Text)
			mouseConnection = mouse.Button1Down:Connect(function()
				if not writing then writing = true
					int = int + 1
					if int > #chatsTable then
						plr.PlayerGui.NPCChat.Enabled = false
						Prompt.Enabled = true
						mouseConnection:Disconnect()
						chatsTable = nil
						wait(0.2)
						chatting.Value = false
						return
					end
					if chatsTable[int].Question then
						settext(chatsTable[int].Text)
						plr.PlayerGui.NPCChat.Options.Option1.Text = chatsTable[int].Option1[1]
						plr.PlayerGui.NPCChat.Options.Option2.Text = chatsTable[int].Option2[1]
						plr.PlayerGui.NPCChat.Options.Visible = true
						yesConnection = plr.PlayerGui.NPCChat.Options.Option1.MouseButton1Down:Connect(function()
							plr.PlayerGui.NPCChat.Options.Visible = false
							if chatsTable[int].Option1.funct then
								chatsTable[int].Option1.funct()
							end
							settext(chatsTable[int].Option1[2])
							yesConnection:Disconnect()
							noConnection:Disconnect()
							writing = false
							if chatsTable[int].Player then
								ChattingGUI.NameLabel.NPCName.Text = "Me"
								settext(chatsTable[int].Text)
								print ('pass 4')
							elseif chatsTable[int].NPC then
								ChattingGUI.NameLabel.NPCName.Text = v.Name
								settext(chatsTable[int].Text)
							end		
						end)
						noConnection = plr.PlayerGui.NPCChat.Options.Option2.MouseButton1Down:Connect(function()
							plr.PlayerGui.NPCChat.Options.Visible = false
							if chatsTable[int].Option2.funct then
								chatsTable[int].Option2.funct()
							end
							settext(chatsTable[int].Option2[2])
							yesConnection:Disconnect()
							noConnection:Disconnect()
							writing = false
						end)
					else
						settext(chatsTable[int].Text)
						writing = false
					end
				end
			end)
		end
	end)
end

Thank you so much for your help!

Do for the player name:

TextLabel.Text = Game.Players.LocalPlayer.Name

Do for the npc name:

TextLabel.Text = v.Name

How do I apply it to the module so it won’t be a lot of work…

Maybe create a second settext but setname?
Example of calling -

SetName(<npcname>)
SetName(Game.Players.LocalPlayer.Name)

Or you could edit your SetText function to

local function settext(Label, Sentance)
	Label.Text = ""
	for i = 1, string.len(sentence) do wait(0.025)
		Label.Text = string.sub(sentence, 1, i)
	end
end

And call it like:

SetText(ChattingGUI.NameLabel.NPCName, v.Name)
SetText(ChattingGUI.NameLabel.NPCName, "Me")