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
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
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
Sorry for the bump, but I just found a solution to this for anyone looking. This type of thing was unacceptable for my game, and I found the Roblox script you can modify to prevent the double bubbles. Basically preventing the bubble chat from copying what dialogs say. This also works for NPCs who you make talk using ChatService, just preventing bubblechat from duplicating things on non-player instances.
If you open up the BubbleChat script under Chat, scroll down to around line 650. You are looking for the function “OnGameChatMessage” This function is specifically for bubbles by game instances, not players.
The reason we add the “if true then” is just so Roblox doesn’t highlight everything after the return statement. It isn’t exactly required, but makes the code editor a lot happier.
So you want to remove the dialogue bubble and keep the bubble chat bubble? I don’t believe removing the dialogue bubble would be possible, but that is what you would need to find out how to do.