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

How to monitor chat?

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

2 answers

✓ Accepted answer

.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
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.

4 comments

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!".

0

Players don't join before the script is done loading online.

0

That isn't necessarily a true statement.

0

It's true so long as it isn't ran locally.

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