Guest User

Find a player function

a guest
Dec 3rd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1. local function findPlayer(name)
  2.     -- Even without the full username and improper caps you can find a player.
  3.     for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
  4.         if player.Name:lower():sub(1, #name) == name then
  5.             return player -- Return the targeted player.
  6.         end
  7.     end
  8.     return nil -- Return nil if no player was found. This is only reached if the above was not met.
  9. end
  10.  
  11. print(findPlayer("Sj")) --> sjr04Alt (if im in game)
Advertisement
Add Comment
Please, Sign In to add comment