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
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
--1337Zombiegamer-- local SpawnPool = {"Citizen", "Citizen1", "Citizen2", "Citizen3"} local NPC = game.Lighting.Citizen while true do local NPCCopy = NPC:Clone() NPCCopy.Parent = Workspace wait(30) end
using math.random to spawn it in to the world from the lighting
Citizen = --Directory here Citizen 1 = --Directory here --and over until u got all of them Citizens = {Citizen, Citezen 1, etc, etc} while wait() do RCitizen = Citizens[math.random(1, #Citizens)] --1 is how many are picked CRCitizen = RCitizen:clone() CRCitizen.Parent = game.Workspace wait(30) end
You see here
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
local Bricks = {"Brick1", "Brick2"} Workspace.Bricks[1]:Clone().Parent = Workspace.Model -- Clones Brick1 Workspace.Bricks[2]:Clone().Parent = Workspace.Model -- Clones Brick2