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

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

Asked by
IcyEvil 260 Moderation Voter
8 years ago

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

1 answer

Log in to vote
0
Answered by 8 years ago

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)

Ad

Answer this question