Currently, I have been trying to make an admin commands system, it works fine but the problem is if I write the players name in lowercase, it never works, is there any way for me to make it so even when the players name is written in lowercase it works?
01 | local headadmins = { '' } |
02 | local admins = { '' } |
03 | local lowadmins = { '' } |
04 | local prefix = "!" |
05 |
06 | game.Players.PlayerAdded:Connect( function (plr) |
07 | plr.Chatted:Connect( function (eeelol, recipent) |
08 | local message = string.lower(eeelol) |
09 | local splitmessage = message:split( " " ) |
10 | local command = splitmessage [ 1 ] |
11 | local maincommand = command:split(prefix) |
12 |
13 | local commandname = maincommand [ 2 ] |
14 |
15 | local playername = eeelol:split( " " ) [ 2 ] |
You can use the string.lower()
method in order to convert any and all uppercase letter of the player's username to lowercase, you can use this to achieve what you have asked.
I'm not sure if this is the best way to do it but I would get a list of all players in the game, then do a for loop with an if
statement inside of it.
To give an example:
1 | local PLAYER_NAME = "Nep_Ryker" -- The player you want to kick |
2 |
3 | for i, v in pairs (game.Players:GetChildren()) do |
4 | if string.lower(v.Name) = = string.lower(PLAYER_NAME) then -- If the lowered case version of v.Name equals to the lowered case version of the player name, then kick |
5 | v:kick() |
6 | else |
7 | print ( "Player not found!" ) |
8 | end |
9 | end |
I hope this helped you somewhat.