I think only the spawner but disabling the script still doesn’t fix it
local rep = game.ReplicatedStorage
local updateTimers = rep.UpdateTimers
local formatNumber = require(rep.FormatNumbers)
local enemies = game.ReplicatedStorage.Enemy:GetChildren()
local seconds = 60
local wave = 0
local spawns = workspace.Spawns:GetChildren()
local requiredBalls = 2
task.wait(2)
repeat
task.wait(1)
if seconds ~= 0 and wave ~= 3 then
seconds -= 1
updateTimers:FireAllClients(formatNumber.convertToMinutesAndSeconds(seconds))
local canSpawn = math.random(1,10)
if canSpawn >= 3 then -- 70% chance to spawn
local enemyToSpawn = enemies[math.random(1, #enemies)]
local randomSpawnPoint = spawns[math.random(1, #spawns)]
local enemyClone = enemyToSpawn:Clone()
enemyClone.HumanoidRootPart.Position = randomSpawnPoint.Position
enemyClone.Parent = workspace
enemyClone.HumanoidRootPart:SetNetworkOwner()
end
elseif seconds <= 0 then
-- Next Wave Starts Here
if workspace.Deposit.CurrentGolds.Value >= requiredBalls then
wave +=1
seconds = 60 -- Reset to starting value
requiredBalls += 5
else
for i, v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid.Health = 0
end
end
end
until wave == 3
I tested it out with multiple NPCs at once and it still worked well, so something must be wrong in your game specifically. Try disabling the spawning script, and just insert the NPCs workspace. Let me know what happens
I did all the things you suggested and I found that this code works which I may use temporarily
local SSS = game:GetService("ServerScriptService")
local SimplePath = require(game.ReplicatedStorage.SimplePath)
--local module = require(game.ReplicatedStorage.AI.GetClosestPlayer)
--Define npc
local Dummy = script.Parent
--Create a new Path using the Dummy
local Path = SimplePath.new(Dummy)
--Helps to visualize the path
Path.Visualize = true
local rs = game:GetService('RunService')
rs.Heartbeat:Connect(function()
if Dummy.Humanoid.Health >= 1 then
local char = SimplePath.GetNearestCharacter(script.Parent.HumanoidRootPart.Position)
Dummy.Humanoid:MoveTo(char.HumanoidRootPart.Position)
end
end)
This other code I tried while debugging gave me two different values so it could be the issue.
local SSS = game:GetService("ServerScriptService")
local SimplePath = require(game.ReplicatedStorage.SimplePath)
--local module = require(game.ReplicatedStorage.AI.GetClosestPlayer)
--Define npc
local Dummy = script.Parent
--Create a new Path using the Dummy
local Path = SimplePath.new(Dummy)
--Helps to visualize the path
Path.Visualize = true
local rs = game:GetService('RunService')
rs.Heartbeat:Connect(function()
if Dummy.Humanoid.Health >= 1 then
local char = SimplePath.GetNearestCharacter(script.Parent.HumanoidRootPart.Position)
print(Path._position)
print( SimplePath.GetNearestCharacter(script.Parent.HumanoidRootPart.Position).HumanoidRootPart.Position)
Path:Run(char.HumanoidRootPart)
end
end)