Advertisement
Meliodas0_0

Usernsme generator

Jan 12th, 2020
5,662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. I made a script that can be used to generate untaken roblox names (It is scripted to get 4 char names).
  2. I don't know if this works with exploits or not, I've been testing it in roblox studio (as a server script).
  3. Note: It just alerts you in dev console that the name is not taken, it doesn't actually create the account for you.
  4.  
  5. There are some variables at the beginning you can set to change results (I don't know if the underscore variable works or not, lmao). I recommend keeping numbers enabled as no number-names are rare, haven't gotten any finds
  6.  
  7. After I finished I realized I could make a table with all possible four char combinations, rather than using a cache and a math.random() on a random index of a table full of characters, I'm gonna post this post and then try and work on that. Was running this for a while and all of a sudden 8char names start popping up, I made an oopsies somewhere, i think i added a fix but not sure if it works.
  8.  
  9. no bulli for how i script pls
  10.  
  11. https://developer.roblox.com/en-us/api-r...mNameAsync this is the roblox API that I use in the script
  12.  
  13.  
  14.  
  15. Cons (so far):
  16.  
  17. It is slow.
  18. Sometimes the username is inappropriate and cannot be used, but will show up since there is no user with that name
  19.  
  20.  
  21. Code:
  22. players = game:GetService("Players");
  23.  
  24.  
  25. underscoreOkay = true; -- change to true if you want an underscore visible in the username, false if you don't want them there', this may be broke, idk
  26.  
  27. numbersOkay = true; -- change to true if you want numbers visible in username, false if you dont want them there
  28.  
  29. nameLength = 4; -- 4 char usernames will be attempted to be generated (This value can be changed)
  30.  
  31.  
  32. charTable = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; -- list of characters
  33.  
  34.  
  35.  
  36. if (underscoreOkay == true) then
  37. table.insert(charTable, "_"); -- insert underscore for generation, there will be hard check in generation to make sure this can only be used once
  38. end;
  39.  
  40. if (numbersOkay == true) then
  41. for i = 0,9 do
  42. table.insert(charTable, tostring(i)); -- insert each number into table for generation
  43. end;
  44. end;
  45.  
  46. local cache = {};
  47.  
  48.  
  49. function generateRandom() -- this abomination made sense to me when i scripted it
  50. local ret = ""; -- this will store the username
  51.  
  52. repeat wait() -- this nasty critter is needed so the nasty repeat doesnt crash us
  53. local isDone = false;
  54. for i = 1,nameLength do
  55. local nextChar;
  56. local underscoreAmount = 0;
  57. local underscoreDone = false; -- this will help with underscore checks; if it is true, an underscore has already been used
  58. repeat
  59. wait(); -- this nasty critter is needed so the nasty repeat doesn't crash us
  60. local isDoable = false;
  61. nextChar = charTable[math.random(1, #charTable)];
  62. if (underscoreAmount == 0 and nextChar == "_" and underscoreDone == true or nextChar == "_" and i ~= 1 or nextChar == "_" and i ~= nameLength) then -- if char position == last or first position and nextChar is underscore, of if underscore has been used once
  63. -- I think I made logic error somewhere in these comparisons but it seems to work
  64. underscoreAmount = 1;
  65. underscoreDone = true;
  66. else
  67. isDoable = true;
  68. end
  69. until isDoable == true;
  70. ret = ret .. nextChar; -- append the randomly generated character to the returning string.
  71. end;
  72.  
  73. if (cache[ret] == nil and ret:len() == 4) then -- if the name has already been used in the generation, repeat the loopity loop
  74. cache[ret] = true; -- it is now in the cache
  75. isDone = true; -- end the loop
  76. end
  77. until isDone == true;
  78.  
  79. return ret;
  80. end;
  81.  
  82.  
  83. function checkPlayer(name)
  84. local bet = "_";
  85. local isPlayer = false;
  86. local x, y = pcall(function()
  87. bet = players:GetUserIdFromNameAsync(name);
  88. end);
  89.  
  90. if (y == nil) then
  91. isPlayer = true; -- there is no need to set it to false in an else statement as it is already false.
  92. end;
  93.  
  94. return (isPlayer); -- return boolean of whether the username exists or not. If username exists, return true, if it does not, return false
  95. end;
  96.  
  97. while wait() do -- will exe 100 times, will probably only give off like 5 results idk
  98. local newName = generateRandom();
  99. if (checkPlayer(newName) == false) then
  100. print("Untaken name: " .. tostring(newName)); -- THIS WILL WARN THE USERNAME IF IT IS NOT TAKEN
  101. end;
  102. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement