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

How to monitor chat?

Asked by
Mowblow 117
10 years ago

How would I wait in the chat for someone to say, for example "Pie is cool!".

2 answers

Log in to vote
2
Answered by 10 years ago

.Chatted event is what detects chat. However, you'll need to connect it to everyone:

Normal script in ServerScriptService:

function newPlayer(p)
    p.Chatted:connect(function(msg)
        if msg == "Pie is cool!" then
            -- Stuff you want to happen (use p to reference the player who said it)
        end
    end)
end
game.Players.PlayerAdded:connect(newPlayer)
for _,v in pairs (game.Players:GetPlayers()) do
    newPlayer(v)
end
Ad
Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg=="Pie is cool!"then
            print(player.Name.." chatted \"Pie is cool!\"")
        end
    end)
end)

The Chatted event listens to everything a player says.

0
You didn't connect the early-birds to the function. It's not considered incorrect, but it just means that if a player joins the game before the script is done loading, they won't get any effect when they chat "Pie is cool!". DiamondBladee 135 — 10y
0
Players don't join before the script is done loading online. 1waffle1 2908 — 10y
0
That isn't necessarily a true statement. DiamondBladee 135 — 10y
0
It's true so long as it isn't ran locally. 1waffle1 2908 — 10y

Answer this question