Okay so here is the code:
chatlog = script.Parent.ChatLog local chat = {} game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) chatlog.Value = player.Name..": "..msg table.insert(chat, chatlog.Value) for i=1,player do print(i) print (chat[i]) end end) end)
I want it to add the value of chatlog every time function(msg) runs to the table. I believe the problem is the for loop. Thanks.
Your error is at line 7, I don't know what you're writting 1, player because a player is a userdata and not a number so you can't use it in this loop. your code fix here:
chatlog = script.Parent.ChatLog local chat = {} game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) chatlog.Value = player.Name..": "..msg table.insert(chat, chatlog.Value) for i=1, #chat do print(i) print (chat[i]) end end) end)
And if you want to see all things in the table you simple need to do this:
chatlog = script.Parent.ChatLog local chat = {} game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) chatlog.Value = player.Name..": "..msg table.insert(chat, chatlog.Value) for i, v in pairs(chat) do print (i, v) end end) end)