Example: The player's name is "lolnuub0204" and i only typed "lol." How would i make a script that finds "lolnuub0204" from just "lol"?
COMMUNITY QUESTION
How would you find the closest player name to what you typed?
2 answers
string.find()
This function will return a table of all players that match the search query.
findMatches = function(Query)
local Matches = {}
for i, v in pairs(game.Players:GetPlayers()) do
if string.sub(string.lower(v.Name), 1, #Query) == string.lower(Query) then
table.insert(Matches, v)
end
end
return Matches
end
for i, v in pairs(findMatches("lol")) do
v.Character.Humanoid.Health = 50
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
