Z_V
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2638 |
|
|
| 28 Jun 2016 01:45 PM |
I've never used table.insert before and it's a little tricky trying to work out what I'm trying to do.
I've created a UI which will output what people chat, but due to the fact that it will be removed from the player GUI and then created again at a later date, I need it to remember what was inputted.
This script will print what people chat, but also what they chatted before, so if I said "hello" and then "hi" and then "asd" it would output hello *chats hi* hello hi *chats asd* hello asd
How would I change it so it only outputs what the player just spoke while retaining the information in the table?
Q = {} for Z,X in pairs(game.Players:GetChildren()) do X.Chatted:connect(function(msg) table.insert(Q, X.Name.." : "..msg) print(string.format(table.concat(Q, '\n')), Color3.new(1, 1, 1)) end) end
|
|
|
| Report Abuse |
|
|
Z_V
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2638 |
|
| |
|
Z_V
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2638 |
|
| |
|
|
| 28 Jun 2016 02:23 PM |
You're doing table.concat, why would you do that if you don't want to print the whole table? And PlayerAdded would probably work better in a game than just iterating. |
|
|
| Report Abuse |
|
|
Z_V
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2638 |
|
|
| 28 Jun 2016 02:25 PM |
what would I use otherwise?
|
|
|
| Report Abuse |
|
|
|
| 28 Jun 2016 02:29 PM |
Something that doesn't print the whole table, since you don't want to based on your post.
Q = {} game.Players.PlayerAdded:connect(function(X) -- I switched to this so it works better. X.Chatted:connect(function(msg) table.insert(Q, X.Name.." : "..msg) print(Q[#Q]) -- Print the last element of Q, the new one. Oh, and Color3s don't change the color of "print". end) end)
|
|
|
| Report Abuse |
|
|
Z_V
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2638 |
|
|
| 28 Jun 2016 02:33 PM |
Oh right thanks!
- The colours after it were to do with the output system I created. The colours simply changed the colour of the text
|
|
|
| Report Abuse |
|
|