Message System Doesn't Work

Hello, developers. I tried making a message system. Basically, when a player steps on the block and says something, their chat will be broadcasted in a message.

However, when the player wants to chat something new, it doesn’t put that on a message. When you go off and back on the block, it displays the past message instead of displaying nothing.

Here is my code. (Yes I will filter it)

local msg = Instance.new("Message",workspace)

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		script.Parent.Touched:Connect(function()
			msg.Text = message
			wait(2)
			msg.Text = ""
		end)
	end)
end)

You should not be making a new connection every time a player chats.

Could you explain how I could do that?

What Vong means is to move the touched event.


game.Players.PlayerAdded:Connect(function(player)
    local MessageToSend = ""
	player.Chatted:Connect(function(message)
        MessageToSend = message
	end)

	script.Parent.Touched:Connect(function()
		msg.Text = MessageToSend
		wait(2)
		msg.Text = ""
	end)
end)
2 Likes

I don’t think touch event will work if he was standing and not moving.

Just wanted to point this out