How can I get a player's character and humanoid from a server-side script?
I've searched through so many devforum posts yet I have not found an answer. I need to find the character to get the humanoid so when a player activates an admin command to kill a player, the player stated is killed.
Here's my script.
Once again, it's a server script.
01 | commands.kill = function (sender, arguments) |
03 | print ( "Kill command fired by " ..sender.Name) |
04 | local plrToKill = arguments [ 1 ] |
05 | if plrToKill = = "me" then |
06 | plrToKill = string.lower(sender.Name) |
07 | arguments [ 1 ] = plrToKill |
09 | local plrChar = game.Workspace:FindFirstChild(plrToKill) |
12 | local plr = findPlayer(plrToKill) |
19 | plrHum = plrChar.Humanoid |
22 | health = plrHum.Health |
Everything else works fine, but I get an error saying "attempt to index nil with 'Humanoid' which I find very confusing. Any help is greatly appreciated.