How would I make it so that the npcs spawn in the script.parent (part).
The npcs torso spawns in the part but they keep spawning in 0,0,0 and not the part area. Im also trying to make it randomized in the area
npcs parents are in parts but not spawning on the part
Instead theyre spawning in here?
local function spawnEnemy(character)
enemiesSpawned=enemiesSpawned+1
local npc=character:Clone()
local humanoid=npc.Humanoid
local torso=npc.Torso
npc.Parent=script.Parent
npc:MakeJoints()
local area = script.Parent
local xVectorRandom = area.CFrame.RightVector * area.Size.X * (math.random(-50, 50) / 100)
local yVectorRandom = area.CFrame.UpVector * area.Size.Y * (math.random(-50, 50) / 100)
local zVectorRandom = area.CFrame.LookVector * area.Size.Z * (math.random(-50, 50) / 100)
local randomarea = xVectorRandom + yVectorRandom + zVectorRandom
torso.CFrame=CFrame.new(randomarea)
humanoid.Died:connect(function()
enemiesSpawned=enemiesSpawned-1
wait(5)
npc:Destroy()
end)
wait()
humanoid.HealthChanged:connect(function()
bloodify(torso)
end)
return npc
end