Chat message being sent twice?

In my game I have set up custom /e animations (dance, laugh, etc) and they work fine but whenever I type “/e (emote)” it plays an animation, and then a split second later it plays the animation a second time even though I only chatted once. I’ve noticed this weird issue happens only on servers with more than 1 player active. When I check what is in my character, there are no duplicate scripts at all. This even happens in other games too.

Here’s what I mean:
IMG_1875

Whenever I say “/e dance”, it plays an animation, then a split second later plays another one.

This also happens with other chat related scripts. I made a fly script that lets you fly and unfly by saying “/toggleFly”, but due to the message somehow being registered twice it looks like the script doesn’t make you fly at all.

code needs to be providen… kldl

You are probably creating a new event every time someone joins the game. Like @pumpkyrofl said, we need to see your script.

1 Like

It’s just a simple Player.Chatted connection. It happens on every script I test it on and also in other games too.

1 Like

It wasn’t always this way either it just started a few weeks back

Check if you have any other Player.Chatted events.

Nope

This is all that is in my script

player.Chatted:Connect(function(message)
	if message == '/e dance' then
		local randomDance = math.random(1, 3)
		if randomDance == 1 then
			danceAnim1:Play()
		elseif randomDance == 2 then
			danceAnim2:Play()
		elseif randomDance == 3 then
			danceAnim3:Play()
		end
		print('test')
	end
end)

It even prints “test” twice.

One thing you could do is try adding a cooldown to the script.

local cooldown = 1
local debounce = false
player.Chatted:Connect(function(message)
    if debounce then return end
	if message == '/e dance' then
		local randomDance = math.random(1, 3)
		if randomDance == 1 then
			danceAnim1:Play()
		elseif randomDance == 2 then
			danceAnim2:Play()
		elseif randomDance == 3 then
			danceAnim3:Play()
		end
        debounce = true
		print('test')
        task.wait(cooldown)
        debounce = false
	end
end)

I think this is a bug on Roblox’s end.

Oh I know why now If you would like me to tell you.

I just randomly clicked on this thread again and thought of something on the spot.

Have you tried removing the Chatted event in the player’s animation script? It’s located in the character. This is probably what’s causing the issue.

I use my own custom animation script