I want this function to print once a player has chatted and the variable is true.
The problem is that it prints twice, and remote event is fired twice.
I’ve tried adding a debounce, (it didn’t work). I’ve also tried counting the number of messages
the player sends, for example
if #Messages == 2 then
It will work if I type it like this.
(and still do it twice)
If I type it like this,
if #Messages == 1 then
Then it will not work, therefore I concluded that it detects 2 messages at a time, strangely,
and it’s not a debounce issue.
And keep in mind that I’m only chatting once.
Player.Chatted:Connect(function(Message)
local filter = game.ReplicatedStorage.FilertingFunction:InvokeServer(Message)
if MicrophoneActive then
print("Firing")
REvent:FireServer("NewMessage", filter, Channels[Channel].Frequency, "Default")
end
end)
What I am saying is that the print command prints “Firing” 2 times because the client prints one and the script that responds to the remote event also prints one. Check the color to the left of the prints, if one is blue and one is green, then my prediction is right.
Player.Chatted:Connect(function(Message)
print("1")
local filter = game.ReplicatedStorage.FilertingFunction:InvokeServer(Message)
print("2")
if MicrophoneActive then
print("Firing")
REvent:FireServer("NewMessage", filter, Channels[Channel].Frequency, "Default")
end
end)
local Enabled = true
Player.Chatted:Connect(function(Message)
if Enabled then
Enabled = false
local filter = game.ReplicatedStorage.FilertingFunction:InvokeServer(Message)
if MicrophoneActive then
print("Firing")
REvent:FireServer("NewMessage", filter, Channels[Channel].Frequency, "Default")
end
end
wait(2) --When this is going to be enabled again
Enabled = true
end
end)
Here’s a suggestion, delete the script, test it. If it still prints, there are multiple scripts. To find those scripts, just click on the print in the output and you should be led t the script. Ten right click on the script and click, “Show on explorer”.
I tried that, I don’t have multiple scripts. I also checked my code, and I don’t have multiple of the same code. I also clicked both of the prints, and it led me directly back to the same script I am using.