I was wondering how I would find the name of closest players name? Lets say I want to go ahead and say something like kill void or something. It would run and kill me. So far Ive been using this code which doesnt find the nearest target
player.Chatted:Connect(function(message) -- trying to make and admin script
if checkifadmin(player) then
if string.lower(string.sub(message,1,string.len("kill")))== "kill" then
print("Working")
local target = game.Players:FindFirstChild((string.lower(string.sub(message,6))))
local targetname = target.Name
local charecter = game.Workspace:WaitForChild(targetname)
print(charecter)
charecter.Humanoid.Health = 0
end
end
end)

5 comments
I can explain more because i made admin once
Could you explain how I use string.find?
She literally just explained it for you. How is this not clear enough?
No what to input in it i don't understand the output and input of string.find?
note string.find will return nil if it does not find anything of the sub string