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

How to see if a player chatted a valid players name that is in the game?

I am wanting to make some admin commands, but im not sure how to do this, Any help?

1 answer

✓ Accepted answer

To listen to a player's chat event, you need PlayerEntered and Chat events (see any admin script for how these work).

To check to see if a string contains a player's name, simply use a loop:

s = "nameHere"
players = game.Players:GetPlayers()
found = false
for i = 1, #players do
	if players[i].Name == s then found = true end
end
--use "found" here

Check out the Vote to Kick Player Script (in Roblox Studio, Toolbox, Roblox Sets), which has an even better implementation (it lets you only type in a part of a player's name, so long as it isn't ambiguous)

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