Ok,so I was making a chat log and I wanted to make a ChatAdded event but then I had a hard time thinking how to check if something has been added to the table so then I came with getting the number of chats in a moment then subtracting it the number of chats once the player has chatted but it didn't work.
TLDR: Is there another way I can check if a new value has been added in the table?
ChatLog = {}
--------------------Vairbles----------------------------
NewChatAdded = script.NewChatAdded
------------------Functions-----------------------------
function ChatLogInsert(String)
table.insert(ChatLog,#ChatLog,String)
end
----------------------Events----------------------------
NewChatAdded.Event:connect(function()
while wait() do
ChatLogNow = #ChatLog--Kinda Like Tick()
ChatLogLater = #ChatLog
NewChats = math.floor(ChatLogNow-ChatLogLater)
if NewChats > 0 then
print("New chats!")
return true
else return false
end
end
end)
---------------------------------------------------------
game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:connect(function(Chat)
ChatLogInsert(Chat)
NewChatAdded:Fire()
end)
end)

1 comment
If I do pass the message as a argument,then how will I change it like Ex : function (this)<---- How would I change this?