Question About Generating

Hello, Dev Community!

I need a way to randomly generate a name from a string of pre-set words. I don’t know where to start.

Any help appreciated!

Thanks,
Ben

Oops, accidently posted, let me edit

Just pick words from each table with math.random:

local firstNames = {"John", "David", "Alice"}
local lastNames = {"Wight", "Greene", "Brown"}

local randomFirstName = firstNames[math.random(1, #firstNames)] -- Picking random from the "firstNames" table
local randomFirstName = lastNames[math.random(1, #lastNames)] -- Picking random from the "lastNames" table

local newName = randomFirstName .. " " .. randomLastName -- New name!
3 Likes

When doing this make sure your result is filtered.

I don’t think it’s necessary since he is using preset words/names?

2 Likes

Roblox requires filtering in all circumstances in where something random may pop up on screen.