I don't know why this event won't fire when I chat why and how could I make it fire? I'm guessing it wont fire because it keeps getting 0 (line 18). I'm using the server console and there's no error.
ChatLog = {}
--------------------Vairbles----------------------------
NewChatAdded = script.NewChatAdded
ChatValue = script.Chats
------------------Functions-----------------------------
function ChatLogInsert(String)
table.insert(ChatLog,#ChatLog,String)
return String
end
----------------------Events----------------------------
game.Players.PlayerAdded:connect(function(Player)---ChatAddedEvent
Player.Chatted:connect(function(Chat)
ChattedString = ChatLogInsert(Chat)
ChatValue.Value = #ChatLog
NewChatAdded.Event:connect(function()
ChatNow = #ChatLog
NumberOfNewChats = math.floor(ChatValue.Value - ChatNow)
if NumberOfNewChats > 0 then
print("New Chat!")
print("The Chat is "..ChattedString)
end
end)
end)
end)
---------------------------------------------------------
game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:wait()
NewChatAdded:Fire()
end)

2 comments
In general, I wouldn't name anything its classname because certain variables can cause errors in your program. In other words I wouldn't return String.
Also, I have NO idea what you are attempting to do. I'll need more of an explanation. I don't know what the point of the if NumberOfNewChats > 0 then statement is, or why you add a new event..? I think you might be attempting what you're doing the wrong way.