How do I Pick a Random Username from Roblox?

Hi, I was wondering: how do I make a script pick a random username from the whole of Roblox?

1 Like

You would probably use math.random() and the minimum would be 1 to however many accounts are on Roblox (or just around like 450 million). and with that number use game.Players:GetNameFromUserIdAsync() to get the name. Script would look like this:

local id = math.random(1, 450000000)

print(game.Players:GetNameFromUserIdAsync(id))
4 Likes

Why are you excluding accounts above id 450,00,000?

There are over 2 billion Roblox accounts

I honestly didn’t know there were that many players on Roblox. :sweat_smile:

there’s not, a billion and half are bot/throwaway accounts (that’s a guess no idea if it’s accurate)

I was also thinking about this topic. But then It made me think about generating random audio Ids :thinking:
Is it possible to get a random audio id from script? :face_with_raised_eyebrow:

It would be possible if most of the audios weren’t removed. For names, it returns it whether the player was banned or not. For audios, it’ll cause errors. It’s probably better to just put as many audios as possible into a table and get them from there.

But what if a user with that UserId doesn’t exist? Wouldn’t the script error?

A UserId will always exist unless its never been used. UserId’s aren’t deleted, just banned.

Well what if the name chosen is innapeopriate?

You could wrap it into pcall and then check if you get successful response or not.

Again, they dont delete the account, they just ban it. If a name is inappropriate it’ll most likely just be tagged or return an error, where you should already be using a pcall.

local RandomUserId = math.random(1, 2000000000)
local Username = game:GetService('Players'):GetNameFromUserIdAsync(RandomUserId)
print(Username)
1 Like