Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I return a string of something a player said and their name?

Asked by
CodyDev 70
7 years ago

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:

01local screen = script.Parent.SurfaceGui
02local Players = game:GetService("Players")
03 
04function moveup(t,n) --This adds the message to the screen and scrolls it up
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
View all 22 lines...

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?

1
You should use a LocalScript instead of a ServerScript, this is so you can get the LocalPlayer and check if the LocalPlayer has chatted. if so, fire an event to all the clients that updates the texts or whatever you're trying to do. gmatchOnRoblox 103 — 7y
0
Thank you, this fixed the problem. CodyDev 70 — 7y

Answer this question