I’ve been making a dialogue system for two NPC’s in my game, a Quest npc and a default npc that gives no quest. Each NPC contains a Greeting dialogue line and a quest response dialogue line.
Each NPC has their own MouseButton1Click functions in an If statement checking if they are a quest of default NPC
dialougeGui.Quest.MouseButton1Click:Connect(function()
if prompt.Name == "GetQuest" then
print("Writting Quest Text")
player.PlayerGui.ScreenGui.Click:Play()
dialougeGui.Quest.Visible = false
WriteLine(dialougeGui.Text, config.Lines.Quest.Value)
end
end)
Although the dialogue that plays after you press the Quest button, it merges both NPC’s dialogue despite them being under different proximity prompt If statements.
Both If Statments.
if prompt.Name == "GetQuest" then
prompt.Enabled = false
local char = player.Character
local cam = workspace.CurrentCamera
local dialougeGui = player.PlayerGui.ScreenGui.Dialouge
dialougeGui.Visible = true
--prompt.Parent.Parent.Head.Status.Enabled = false
local config = prompt.Parent.Parent.Dialouge
for i,v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
v.Transparency = 1
end
end
dialougeGui.BackgroundColor = config.QuestColor.Value
dialougeGui.Title.BackgroundColor = config.QuestColor.Value
dialougeGui.Title.Text = prompt.Parent.Parent.Name
dialougeGui.Quest.Text = config.QuestName.Value
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(prompt.Parent.Parent.CamPart.Position) * CFrame.Angles(math.rad(prompt.Parent.Parent.CamPart.Orientation.X), math.rad(prompt.Parent.Parent.CamPart.Orientation.Y), math.rad(prompt.Parent.Parent.CamPart.Orientation.Z))
WriteLine(dialougeGui.Text, config.Lines.Greeting.Value)
dialougeGui.Exit.MouseButton1Click:Connect(function()
player.PlayerGui.ScreenGui.Click:Play()
prompt.Enabled = true
cam.CameraType = Enum.CameraType.Custom
dialougeGui.Visible = false
dialougeGui.Quest.Visible = true
dialougeGui.Text.Text = ""
for i,v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
if v.Name == "HumanoidRootPart" then
v.Transparency = 1
else
v.Transparency = 0
end
end
end
end)
dialougeGui.Quest.MouseButton1Click:Connect(function()
if prompt.Name == "GetQuest" then
print("Writting Quest Text")
player.PlayerGui.ScreenGui.Click:Play()
dialougeGui.Quest.Visible = false
WriteLine(dialougeGui.Text, config.Lines.Quest.Value)
end
end)
end
if prompt.Name == "TalkToNPC" then
prompt.Enabled = false
local char = player.Character
local cam = workspace.CurrentCamera
local dialougeGui = player.PlayerGui.ScreenGui.Dialouge
dialougeGui.Visible = true
local config = prompt.Parent.Parent.Dialouge
for i,v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
v.Transparency = 1
end
end
dialougeGui.BackgroundColor = config.QuestColor.Value
dialougeGui.Title.BackgroundColor = config.QuestColor.Value
dialougeGui.Title.Text = prompt.Parent.Parent.Name
dialougeGui.Quest.Text = config.QuestName.Value
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(prompt.Parent.Parent.CamPart.Position) * CFrame.Angles(math.rad(prompt.Parent.Parent.CamPart.Orientation.X), math.rad(prompt.Parent.Parent.CamPart.Orientation.Y), math.rad(prompt.Parent.Parent.CamPart.Orientation.Z))
WriteLine(dialougeGui.Text, config.Lines.Greeting.Value)
dialougeGui.Exit.MouseButton1Click:Connect(function()
player.PlayerGui.ScreenGui.Click:Play()
prompt.Enabled = true
cam.CameraType = Enum.CameraType.Custom
dialougeGui.Visible = false
dialougeGui.Quest.Visible = true
dialougeGui.Text.Text = ""
for i,v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
if v.Name == "HumanoidRootPart" then
v.Transparency = 1
else
v.Transparency = 0
end
end
end
end)
dialougeGui.Quest.MouseButton1Click:Connect(function()
if prompt.Name == "TalkToNPC" then
print("Writting Speech Text")
player.PlayerGui.ScreenGui.Click:Play()
dialougeGui.Quest.Visible = false
WriteLine(dialougeGui.Text, config.Lines.Quest.Value)
end
end)
end
end)
Been at this for hours, Thanks!