generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Table.insert chat log

Previous Thread :: Next Thread 
Z_V is online. 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 is online. Z_V
Joined: 11 Dec 2012
Total Posts: 2638
28 Jun 2016 01:51 PM
*


*chats asd*
hello hi asd


Report Abuse
Z_V is online. Z_V
Joined: 11 Dec 2012
Total Posts: 2638
28 Jun 2016 02:15 PM
b


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is online. Z_V
Joined: 11 Dec 2012
Total Posts: 2638
28 Jun 2016 02:25 PM
what would I use otherwise?


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image