Admin Commands Find Target

Some admin commands do like :kill PartOfSomeOnesName. How do I find a player with that?

Iterate through players and then use string.match() to see if the message the player sent can be found in a player’s name.

Can you give a example? im nee to using string.

1 Like
function getPlayerFromSubString(input)
	input = tostring(input):lower()
	for _, player in ipairs(game:GetService("Players")) do
		if (player.Name:lower():sub(1, #input) == input) then
			return player
		end
	end
end

print(getPlayerFromSubString("blo")) -- Blokav

Yes.

player.Chatted:Connect(function(message)
for I, v in pairs(game.Players:GetChildren()) do
if string.match(string.lower(v.Name),string.lower(msg)) then
-- run the kill script here
break
end
end
end)
1 Like