How can I return a string of something a player said and their name?
I have a monitor that is essentially a chat log, but it's not working properly. The proper message is displayed on the screen, but the username is always the player who joined the game last. I want the username to be the player who actually said the message.
What I have tried:
01 | local screen = script.Parent.SurfaceGui |
02 | local Players = game:GetService( "Players" ) |
05 | screen [ "1" ] .Text = screen [ "2" ] .Text |
06 | screen [ "2" ] .Text = screen [ "3" ] .Text |
07 | screen [ "3" ] .Text = screen [ "4" ] .Text |
08 | screen [ "4" ] .Text = screen [ "5" ] .Text |
09 | screen [ "5" ] .Text = screen [ "6" ] .Text |
10 | screen [ "6" ] .Text = screen [ "7" ] .Text |
11 | screen [ "7" ] .Text = screen [ "8" ] .Text |
12 | screen [ "8" ] .Text = screen [ "9" ] .Text |
13 | screen [ "9" ] .Text = screen [ "10" ] .Text |
14 | screen [ "10" ] .Text = screen [ "11" ] .Text |
15 | screen [ "11" ] .Text = "> [" .. n .. "] : " .. t |
18 | game:GetService( "Players" ).PlayerAdded:Connect( function (p) |
19 | p.Chatted:Connect( function (msg) |
I think this happens because it only listens for chatting from the first player who joined, and after somebody else joins, p is overwritten and msg is not overwritten because it's read only. Obviously, PlayerAdded is not what I should be using. So can anyone help me with this?