So I am trying to make an area-specific NPC spawning. I have different NPCs set up for different areas.
This is my Area setup
And this is the NPC set up for each area. (The NPCs are in the specific folders)
--// Variables
local replicatedStorage = game:GetService("ReplicatedStorage")
local AreasFolder = game:GetService("Workspace"):WaitForChild("Areas")
local AreaNPCsFolder = replicatedStorage:WaitForChild("AreaNPCs")
local AreaNPCs = {}
for _, Area in pairs(AreasFolder:GetChildren()) do
table.insert(AreaNPCs, Area.Name)
local NPCs = AreaNPCsFolder:FindFirstChild(Area):GetChildren()
table.insert(AreaNPCs[Area], NPCs.Name)
end
Basically I want the tabled to be formated as shown:
local AreaNPCs = {
["Spawn"] = {NPC Names Go Here},
["Lava Hot Springs"] = {NPC Names Go Here},
["Nuclear Wasteland"] = {NPC Names Go Here},
["VIP"] = {NPC Names Go Here}
}
I am quite unsure of what's wrong with this so anything helps.

1 comment
Could I get in contact with you on discord? I've sent you a friend request my discord is 0Vyp#9314