Hello,
Does anyone have any articles that can help me make a gui that projects what a player has said in chat?
Thanks
If you mean a chat logs script, then I have the script for it.
Before beginning, you will have to add a ScreenGui
to StarterGui
, and in that ScreenGui add a ScrollingFrame
that contains an UIGridLayout
.
Add a script to ServerScriptService
and name it ChatLogs
Inside the script, add a new table called Logs
local Logs = {} -- That's a table, if I remember
Now we can begin scripting:
First, we will connect to PlayerAdded
and Chatted
events
game.Players.PlayerAdded:Connect(function(Player) Player.Chatted:Connect(function(msg) end end)
Now inside Chatted
we will use table.insert
game.Players.PlayerAdded:Connect(function(Player) Player.Chatted:Connect(function(msg) table.insert(Logs, msg) end end)
Last, we will add a TextLabel
to the scrolling frame using the script
game.Players.PlayerAdded:Connect(function(Player) Player.Chatted:Connect(function(msg) table.insert(Logs, msg) local label = Instance.new("TextLabel", Player.PlayerGui.ScreenGui.ScrollingFrame) -- ScreenGui is the name for the ScreenGui we added at begin and ScrollingFrame is the scrolling frame we added at begin as well label.Text = Player.Name..": "..msg end end)
Note: The table isn't needed, but you might want to add it when the player joins to see what players said before you joined.