I'm making a spawning script that uses a table but I don't know how to use a table other then typing in the what the table will have in it like
1 | local NPC = { "NPC1" , "NPC2" } |
that's all I know how to do with a table but I want to select a citizen from the table in this script
1 | --1337Zombiegamer-- |
2 | local SpawnPool = { "Citizen" , "Citizen1" , "Citizen2" , "Citizen3" } |
3 | local NPC = game.Lighting.Citizen |
4 |
5 | while true do |
6 | local NPCCopy = NPC:Clone() |
7 | NPCCopy.Parent = Workspace |
8 | wait( 30 ) |
9 | end |
using math.random to spawn it in to the world from the lighting
01 | Citizen = --Directory here |
02 | Citizen 1 = --Directory here |
03 | --and over until u got all of them |
04 | Citizens = { Citizen, Citezen 1 , etc, etc } |
05 |
06 | while wait() do |
07 | RCitizen = Citizens [ math.random( 1 , #Citizens) ] --1 is how many are picked |
08 | CRCitizen = RCitizen:clone() |
09 | CRCitizen.Parent = game.Workspace |
10 | wait( 30 ) |
11 | end |
You see here
1 | local NPC = { "NPC1" , "NPC2" } |
In order to fetch these you have to do "Where it's located"[1] or [2]. The way that tables work is in order so for example
1 | local Bricks = { "Brick1" , "Brick2" } |
2 |
3 | Workspace.Bricks [ 1 ] :Clone().Parent = Workspace.Model -- Clones Brick1 |
4 | Workspace.Bricks [ 2 ] :Clone().Parent = Workspace.Model -- Clones Brick2 |