Double dialogue, no errors

ok so i have this npc, with a head that looks at you when u get close
and i’ve put a click detector in the head to make the npc chat
when clicking on the head it now pops up with double chats
and i’ve scanned the script multiple times with no problems
no errors popping up, and it wasnt doing this before

image

script:

local bodyPosition = script.Parent.BodyPosition
local bodyGyro = script.Parent.BodyGyro
local part = script.Parent
local minDist = 10

local message1 = false
local message2 = false
local message3 = false

local chatService = game:GetService("Chat")


bodyPosition.Position = script.Parent.Position

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if message1 == false then
		chatService:Chat(part, "What do you seek young traveler?", "White") 
		message1 = true 
	else
		wait()
		if message2 == false then
			chatService:Chat(part,"You wish to learn holy magic?","White")
			message2 = true
		else
			wait()
			if message3 == false then
				if plr.leaderstats.Level.Value >= 50 then
					if plr.secondaryData.Race.Value == "Vampire" then
						chatService:Chat(part,"You are forbiddden from learning this magic", "Red")
						message1 = false 
						message2 = false
						message3 = false
						return
					else
						chatService:Chat(part,"Very well then, I pass on my knowledge to you.","White")
						print("in testing")
						message1 = false 
						message2 = false
						message3 = false
					end
					
					else
						if plr.secondaryData.Race.Value == "Vampire" then
							chatService:Chat(part,"You are forbiddden from learning this magic", "Red")
							message1 = false 
							message2 = false
							message3 = false
							return
					else
						
						chatService:Chat(part,"Come back when you are level 50","White")
						message1 = false 
						message2 = false
						message3 = false
					end	
				end
			end
			
		end
		
	end	
end)

while wait(.01) do
	local players = game.Players:GetChildren()
	for i = 1, #players do
		local mainPart = workspace:WaitForChild(players[i].Name).HumanoidRootPart
		local magnitude = (part.Position - mainPart.Position).magnitude
		
		if magnitude <= minDist then
			bodyGyro.CFrame = CFrame.new(part.Position,mainPart.Position)
			break
		end
	end
end
1 Like

Hello dear skeleton,
I have come to tell you that this is probably a roblox issue

I have come to tell you that this is probably a roblox issue

And that i have seen this happen in chat sometimes in a few games

And that i have seen this happen in chat sometimes in a few games

But don’t take my word for it! You can ask roblox to fix the issue or there might actually be another solution to this

But don’t take my word for it! You can ask roblox to fix the issue or there might actually be another solution to this

~ Sincerely, @oscoolerreborn
~ ~ Sorry If The Way I Just Wrote Annoys Some People :sad:

When using this script myself (minus the if statements to check player values) it works fine. The possible problems that could be occurring are as following:

  • (most likely) This is a roblox issue, perhaps try using the script inside of another model to see if it works elsewhere. Here is a similar problem with a solution that may help as well: Double Bubble Chat Glitch LOL - #7 by R_obotz
  • The click detector is firing directly after the first if statement and causing it to repeat
  • You have duplicated the script so it is running twice (unlikely, but possible)

Another problem I see within the script (I imagine you just mistyped it) is at

else
if plr.secondaryData.Race.Value == “Vampire” then

as the else is after you ended the if statement.