I’m trying to make that, A random npc spawns on the spawn part.
The spawn part is already finished, The only problem is Npc Randomizing.
Code:
local NPCSpawners = workspace.EnemySpawns:GetChildren()
local NPCS = game.ReplicatedStorage.NPCS
function SpawnRandomNPC()
local RandomSpawners = NPCSpawners[math.random(#NPCSpawners)]
local ChoosenNPC = NPCS[math.random(#NPCS)]
ChoosenNPC.Parent = workspace
ChoosenNPC.HumanoidRootPart.Position = RandomSpawners.Position
end
SpawnRandomNPC()
And what exactly is the issue that’s occurring? This is the kind of information that is needed to make any progress. Just giving code and saying their is a problem doesn’t help.
My first assumption is you aren’t calling :GetChildren() on game.ReplicatedStorage.NPCS. Which means their is no table being assigned to your NPCS variable.
The other issue I see is you are not creating a Clone of your NPCS which means you are removing the NPCS from ReplicatedStorage and putting them in Workspace. Click that link that’s posted and it should help you with using the models stored in ReplicatedStorage to be reference models.