In Game Database

Hi everyone! i’m making a detective style game and i need something like a Database where are stored Names,Surnames,Age and gender of like 100 NPCs

i was wondering if there is an easier way than create 100 StringValues and giving to each one their names as more value, surnames and so on.

Also all infos are randomly generated so the script will need more than 3 table.move for each one being over 300 if there is no way

You can use module scripts for that, essentially have a table storing all the info about NPCs, quick example of the module:

local npcData = {
    [1] = {
          Name = "NPC1",
          Surname = "SurnameOfNPC1",
          Age = 15
          ...
    }
}

return npcData

So basically i will have

A table of 200 names
A table of 200 surnames

randomly Names and surnames will be gived to [1], [2] and so on and i could recall them just using npcData[1], npcData[2] and so on…

Am i understanding right?

Yeah, you are. you can do it like that

local npcData = require(path.to.npc.data.module)

print(npcData[1].Name) --Prints Name property of element 1 in the npcData table.

ok and so i could use npcData.Name or Surname and so on. also to check all the others using a for i,v.
Thank you for help! :smiley:

1 Like