I have a script that handles all the chat commands when they are said the first two work but the last one, the kill cmd, doesn't seem to work. Here is the script:
local admins = {"Ki_ngPhantom"} local banned = {} local prefix = "*" game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) if msg:lower() == prefix.."version" then print("0.01") end if msg:lower() == prefix.."suicide" then plr.Character.Humanoid.Health = 0 end if msg:lower():sub(1, 6) == prefix.."kill " then game.Players:FindFirstChild(msg:lower():sub(6)).Character.Humanoid.Health = 0 end end) end)
It comes up with an error message that says:
17:41:13.224 - Workspace.Ki_ngPhantoms Admin Commands.Main_Script:13: attempt to index a nil value
17:41:13.225 - Stack Begin
17:41:13.225 - Script 'Workspace.Ki_ngPhantoms Admin Commands.Main_Script', Line 13
17:41:13.226 - Stack End
First of all, you are trying to set a humanoid to "0". You got to use either .Humanoid.Health = 0 or .Humanoid:TakeDamage(Humanoid.MaxHealth).
Remove the third "if", replace it with:
if string.sub(msg, 0, 6) == (prefix.."kill ") then local findPlayer = game.Players:FindFirstChild(string.sub(msg, 7)) findPlayer.Character.Humanoid.Health = 0 end
I've tested this in studio, it worked.Tell me if you run into problems.
If it works, tag my answer as answered.