local debounce = false
Player.Chatted:connect(function(Message)
if debounce then
return
end
debounce = true
print("CHATTED!")
--ignore rest of code....
task.wait(1)
debounce = false
end)
What about this?
local debounce = false
Player.Chatted:connect(function(Message)
if debounce then
return
end
debounce = true
print("CHATTED!")
--ignore rest of code....
task.wait(1)
debounce = false
end)
What about this?
It still fires twice:
That’s weird, are you sure you don’t have the same script copied in 2 different locations?
Press CTRL + SHIFT + F and use the global script search to search for “chatted”.
I already made sure of that:
I tried looking around the forum for others who’ve encountered similar issues but this is a first it seems.
Thanks for linking, I’ll take a quick look.
So the lines that I originally mentioned were in a bigger script with a bunch of other functions. So I just tried to put the lines I mentioned above into a new local script with no other lines of code and the output was normal.
I’m guessing not but do you have any custom chat systems in place?
No, only a small system for roblox buble chat, I destroyed that tho and used roblox’s normal system and the same thing happend.
If you had the “Chatted” event in a loop before (which ran twice) then the connected function would execute twice as well. In other words you’d be connecting 2 separate closures (functions) to the “Chatted” event, which when fired would result in both functions being executed.
for i = 1, 2 do
player.Chatted:Connect(function(msg)
print(msg)
end)
end
This is what I’m trying to refer to. Obviously it won’t be that obvious in your script (but I can only assume this is likely what is occurring).
Can I see the definition for “Message”?
I think its built into the function, right?
Oh, you’ve collapse the function, can you expand it by clicking the arrow?
Also “:connect()” is deprecated (not necessarily the issue) but “:Connect()” should be used.
Where do you define Player? The only possible problem is that you have wrote multiple connections to an individual Player’s Chatted event, or that you have wrote multiple connections to PlayerAdded.
These are the only 2 times “player” was referenced before the chatted code.
I assume player will just be a simple “game.Players.LocalPlayer” at the top of the script.