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

Why won't this event fire?[Not Fixed]

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.

Hierarchy

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

0

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.

0

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.

1 answer

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