REMOTES.Chat.OnServerEvent:connect(function(y,q,g)local J if g=="\071\108\111\098\097\108"then J=Players:GetPlayers()elseif g=="\083\113\117\097\100"then local q=GetSquad(y)if q then J={}for y,q in pairs(q.Players:GetChildren())do table.insert(J,Players[q.Name])end end end if not cooldowns[y]then cooldowns[y]=0 end cooldowns[y]=cooldowns[y]+1 if cooldowns[y]<=MAX_PER_SECOND then if J then if string.gsub(q,"\037\115","")~=""then local m=TextService:FilterStringAsync(q,y.UserId)for q,J in pairs(J)do spawn(function()pcall(function()if y.Parent==Players and(J.Parent==Players and Chat:CanUsersChatAsync(y.UserId,J.UserId))then local q=m:GetChatForUserAsync(J.UserId)REMOTES.Chat:FireClient(J,y.Name,q,g)end end)end)end end end else REMOTES.Chat:FireClient(y,"\083\069\082\086\069\082","\087\111\097\104 \116\104\101\114\101\044 \121\111\117\'\114\101 \115\101\110\100\105\110\103 \109\101\115\115\097\103\101\115 \116\111\111 \102\097\115\116\033","\083\101\114\118\101\114")end end)Players.PlayerRemoving:connect(function(y)if cooldowns[y]then cooldowns[y]=nil end end)


REMOTES.Chat.OnServerEvent:connect(function(player, message, scope)
	local players
	
	if scope == "Global" then
		players	= Players:GetPlayers()
	elseif scope == "Squad" then
		local squad	= GetSquad(player)
		if squad then
			players	= {}
			
			for _, p in pairs(squad.Players:GetChildren()) do
				table.insert(players, Players[p.Name])
			end
		end
	end
	
	if not cooldowns[player] then
		cooldowns[player]	= 0
	end
	
	cooldowns[player]	= cooldowns[player] + 1
	
	if cooldowns[player] <= MAX_PER_SECOND then
		if players then
			if string.gsub(message, "%s", "") ~= "" then
				local result	= TextService:FilterStringAsync(message, player.UserId)
				for _, p in pairs(players) do
					spawn(function()
						pcall(function()
							if player.Parent == Players and p.Parent == Players and Chat:CanUsersChatAsync(player.UserId, p.UserId) then
								local filtered	= result:GetChatForUserAsync(p.UserId)
								REMOTES.Chat:FireClient(p, player.Name, filtered, scope)
							end
						end)
					end)
				end
			end
		end
	else
		REMOTES.Chat:FireClient(player, "SERVER", "Woah there, you're sending messages too fast!", "Server")
	end
end)

Players.PlayerRemoving:connect(function(player)
	if cooldowns[player] then
		cooldowns[player]	= nil
	end
end)
