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

gui projects what a player has said in chat?

Asked by 2 years ago

Hello,

Does anyone have any articles that can help me make a gui that projects what a player has said in chat?

Thanks

1 answer

Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
2 years ago

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.

Chatted event

0
Thanks man! Great help lately from ya. Helloimpets 17 — 2y
Ad

Answer this question