I’m stumped and don’t know why I’m getting this error.
ServerScriptService.Mainframe.EnemyHandler:27: ServerScriptService.Mainframe.EnemyHandler:5: attempt to call a nil value - Server - EnemyHandler:27
local Enemy = {}
function Enemy.Move(enemy, map)
local Humanoid = Enemy:WaitForChild('Humanoid')
local Waypoints = map.Waypoints
for waypoint=1, #Waypoints:GetChildren() do
Humanoid:MoveTo(Waypoints[waypoint].Position)
Humanoid.MoveToFinished:Wait()
end
Enemy:Destroy()
end
function Enemy.Spawn(name, quantity, map)
local EnemyExists = ServerStorage.Enemies:FindFirstChild(name)
if EnemyExists then
for i=1, quantity do
task.wait(0.5)
local newEnemy = EnemyExists:Clone()
newEnemy.HumanoidRootPart.CFrame = map.Start.CFrame
newEnemy.Parent = map.Enemies
coroutine.wrap(Enemy.Move)(newEnemy, map)
Enemy.Move(newEnemy, map)
end
else
warn('The requested enemy does not exist:', name)
end
end
return Enemy