How would I make a NPC's (DUMMY) name randomly chosen out of a table?

You can write your topic however you want, but you need to answer these questions:
So, basically, I’m trying to achieve a system where, you play the game, and then there’d be an NPC,
That NPC, will have a randomly chosen name out of the Table I wrote, something like this

local Names = {
“Charley”;
“James”;
“Kyle”;
“Robert”;

}

I’ve tried to do, I,v in pairs to rename every Dummy, a name out of the table shown above, but It won’t work. I’m not asking to be spoonfead, just asking how might I achieve this, which method would be most practical, and beneficial for learning. I’ve tried looking for solutions, but I haven’t stumbled upon anything yet.

1 Like

For what its worth the solution that @dthecoolest linked will work., but was tailored for mixed tables or dictionaries. Since you have an array you can make things simpler:

local index = math.random(#Names) -- some number 1-4
local choice = Names[index] -- e.g. "James"
2 Likes

NPC.Humanoid.DisplayName = Names[math.random(1,#Names)]

I’ll be making yours the new solution, due to yours being more optimized, and generally more easier to understand, thanks for that!

1 Like