Hi, I'm New to both Lua and This site, I just started working with remotes, I'm confused about what is happening with my code, I am making a global Announcement to use Across my Game's servers, What is happening is say I type '/Global Bob' It'll output '[Global] Bob' Into Chat, but then if I then use the command again, let's say '/Global Hello World!' it Would output [Global] Hello World!' Two times, and if I was to do it again, it would output the same way, but three times, so on and so fourth. And I Honestly Have no Idea how to figure it out, I put in a Count to Determine that the Event is Indeed being fired More than Once, but I am stuck, and I would appreciate any help.
Script in Server Script Service:
local messagingService = game:GetService("MessagingService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local chatService = game:GetService("Chat")
local remoteEvent = ReplicatedStorage:WaitForChild("GlobalEvent")
local count = 1
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
local messageCmd = "/global "
local toSend
local toFilter
if string.sub(msg,1,8):lower() == messageCmd then
toFilter = string.sub(msg,8)
toSend = chatService:FilterStringForBroadcast(toFilter, player)
local success, errorMessage, connection = pcall(function()
messagingService:SubscribeAsync("GlobalAnn", function(message)
remoteEvent:FireClient(player, message.Data)
count = count + 1
end)
warn("I Don't Know Why, but We Fired Client ", count, " Times for no Reason :)")
end)
wait(2)
local success, errorMessage = pcall(function()
messagingService:PublishAsync("GlobalAnn",toSend)
end)
end
end)
end)
Thanks for the Help!

1 comment
So the Amount it is firing seems to be directly correlated to the amount of times I've done '/global' so I am wondering if the problem is caused by the script looking through my chat history too, and not just my last message