Here is my code:
function GetPlayer(targetedPlayerName)
for _,player in pairs(game:GetService("Players"):GetPlayers()) do
if targetedPlayerName:lower() == player.Name:sub(1,targetedPlayerName:len()):lower() then
return player
end
end
return nil
end
script.Parent.MouseButton1Click:Connect(function()
local txt = script.Parent.Parent.NameInput.Text
local plr = GetPlayer(txt)
plr.Character:FindFirstChild("Humanoid").Health = 0
end)
Here is a Lightshot Screenshot that shows my Explorer GUI: http://prntscr.com/opbe2m
When I got the error, " 20:51:16.334 - Players.KDarren12.PlayerGui.ScreenGui.Frame.KickButton.Keeeek script:13: attempt to index local 'plr' (a nil value)", I wanted to make sure I targeted the text input correctly, and I did. Any help please?

4 comments
Because there was no player whose name contained the text inputted. You need to check if the player exists first. Also killing players locally won't replicate to the server. You need remote events but this could be abused by exploiters. You're better off using chat commands or something like admin cmds
Ok, I'll try some things out. Also, this was ran into a server script.
Also don't use :len() to get the string length. Instead, use the unary length operator #. #str
I tried many things, but nothing worked