Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I made a script that can be used to generate untaken roblox names (It is scripted to get 4 char names).
- I don't know if this works with exploits or not, I've been testing it in roblox studio (as a server script).
- Note: It just alerts you in dev console that the name is not taken, it doesn't actually create the account for you.
- 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
- 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.
- no bulli for how i script pls
- https://developer.roblox.com/en-us/api-r...mNameAsync this is the roblox API that I use in the script
- Cons (so far):
- It is slow.
- Sometimes the username is inappropriate and cannot be used, but will show up since there is no user with that name
- Code:
- players = game:GetService("Players");
- 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
- numbersOkay = true; -- change to true if you want numbers visible in username, false if you dont want them there
- nameLength = 4; -- 4 char usernames will be attempted to be generated (This value can be changed)
- 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
- if (underscoreOkay == true) then
- table.insert(charTable, "_"); -- insert underscore for generation, there will be hard check in generation to make sure this can only be used once
- end;
- if (numbersOkay == true) then
- for i = 0,9 do
- table.insert(charTable, tostring(i)); -- insert each number into table for generation
- end;
- end;
- local cache = {};
- function generateRandom() -- this abomination made sense to me when i scripted it
- local ret = ""; -- this will store the username
- repeat wait() -- this nasty critter is needed so the nasty repeat doesnt crash us
- local isDone = false;
- for i = 1,nameLength do
- local nextChar;
- local underscoreAmount = 0;
- local underscoreDone = false; -- this will help with underscore checks; if it is true, an underscore has already been used
- repeat
- wait(); -- this nasty critter is needed so the nasty repeat doesn't crash us
- local isDoable = false;
- nextChar = charTable[math.random(1, #charTable)];
- 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
- -- I think I made logic error somewhere in these comparisons but it seems to work
- underscoreAmount = 1;
- underscoreDone = true;
- else
- isDoable = true;
- end
- until isDoable == true;
- ret = ret .. nextChar; -- append the randomly generated character to the returning string.
- end;
- if (cache[ret] == nil and ret:len() == 4) then -- if the name has already been used in the generation, repeat the loopity loop
- cache[ret] = true; -- it is now in the cache
- isDone = true; -- end the loop
- end
- until isDone == true;
- return ret;
- end;
- function checkPlayer(name)
- local bet = "_";
- local isPlayer = false;
- local x, y = pcall(function()
- bet = players:GetUserIdFromNameAsync(name);
- end);
- if (y == nil) then
- isPlayer = true; -- there is no need to set it to false in an else statement as it is already false.
- end;
- return (isPlayer); -- return boolean of whether the username exists or not. If username exists, return true, if it does not, return false
- end;
- while wait() do -- will exe 100 times, will probably only give off like 5 results idk
- local newName = generateRandom();
- if (checkPlayer(newName) == false) then
- print("Untaken name: " .. tostring(newName)); -- THIS WILL WARN THE USERNAME IF IT IS NOT TAKEN
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement