Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a script that displays everything a player says on a TextLabel?

I'm trying to make something like this

If you look in the background, there is a screen displaying everything the host is saying.

I have tried to re-create this. However, I can't figure out how to make it so it only displays what one person says. This is the script I have so far:

local l1 = script.Parent.Frame.TextLabel

function addMessage(player, text)
    l1.Text = "" .. text
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(chat)
        addMessage(player.Name, string.sub(chat, 0))
    end)
        end)

My attempt at making it so it only displays what one person says:

local l1 = script.Parent.Frame.TextLabel

game.Players.PlayerAdded:connect(function(plr)
    if plr.Name == "marmitem0nster" then

function addMessage(player, text)
    l1.Text = "" .. text
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(chat)
        addMessage(player.Name, string.sub(chat, 0))
    end)
        end)

However, the script does not work.

If anyone could help me with this, that would be great.

2 answers

✓ Accepted answer

This one is a pretty simple solution, check who the player is when a message is sent (after player.Chatted:connect(function(chat)) instead of when a player joins.

1 comment

0

Thank you so much! I have been trying to get this to work for ages. I feel really stupid realising it was such an easy fix haha

local l1 = script.Parent.Frame.TextLabel

function addMessage(player, text)
    l1.Text = "" .. text
end

game.Players.PlayerAdded:connect(function(player)
if plr.Name == "marmitem0nster" then
    player.Chatted:connect(function(chat)
        addMessage(player.Name, string.sub(chat, 0))
    end)
end)

try that

This discussion is preserved as it was. New answers, comments, and votes are closed.