Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with events?

I was trying to make a new chat has been added event(Line 16),so I will be able to tell if a new chat has been added to the table but it won't fire,why?

ChatLog = {}
--------------------------------------------------------
NewChatAdded = script.NewChatAdded
--------------------------------------------------------
NewChatAdded.Event:connect(function(ChatAdded)--When a new chat is added it will fire
	NumberOfChats = #ChatLog
	while wait() do--Keeps refreshing
		NumberOfChatsNow = #ChatLog
	end
		print("There were "..NumberOfChats.." Now there is "..NumberOfChatsNow)
end)
---------------------------------------------------------
game.Players.PlayerAdded:connect(function(Player)
	Player.Chatted:connect(function(Chat)
		table.insert(ChatLog,#ChatLog,Chat)--Inserts what the player chatted
			NewChatAdded:Fire()--Fires event
					
	end)
end)

I'm using the Server Console.

1 answer

 while wait() do--Keeps refreshing
NumberOfChatsNow = #ChatLog
end
print("There were "..NumberOfChats.." Now there is "..NumberOfChatsNow)

That would never print because the loops if going forever.

And what exactly is NewChatAdded?

1 comment

0

It's just a bindable event I made so I can create a chat gui later that I can easily control the chat

This discussion is preserved as it was. New answers, comments, and votes are closed.