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
11 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 11 years ago

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

Normal script in ServerScriptService:

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

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 — 11y
0
Players don't join before the script is done loading online. 1waffle1 2908 — 11y
0
That isn't necessarily a true statement. DiamondBladee 135 — 11y
0
It's true so long as it isn't ran locally. 1waffle1 2908 — 11y

Answer this question