you could also try adding a cooldown to the loop and see if that changes anything
sorry i know its been a while but did you remember how you fixed it?
I forgot to check, my bad.
Is this how you want the NPC to move?
robloxapp-20240612-1012549.wmv (2.0 MB)
yes, pretty much although I would rather there not be an delay on the movement because I wanted it to be smooth not too robotic like.
Okay I made it less robotic, I’ll send you the place file in a minute
Thank you so much. I’ll check it when I get the chance.
Your game works in the empty baseplate but its not working when I import it into my game, so it must be some other script in my game.
Thats strange, do you have a video of it happening?
robloxapp-20240613-2100513.wmv (2.6 MB)
The third one isn’t moving because i’m doing modifications on it to find the problem
it could be possibly performance issues?
Or because GetNearestCharacter returns any character, not just a player.
From looking at the module it should only get players
function Path.GetNearestCharacter(fromPosition)
local character, dist = nil, math.huge
for _, player in ipairs(Players:GetPlayers()) do
if player.Character and (player.Character.PrimaryPart.Position - fromPosition).Magnitude < dist then
character, dist = player.Character, (player.Character.PrimaryPart.Position - fromPosition).Magnitude
end
end
return character
end
--Code from module
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 do have to log off rn but I’m thinking I may have to create a new baseplate then move everything from the existing game into the new baseplate.
i’ve done both of those but it still did the same thing, its weird.
If you copy everything from the old game and paste it into the new one you may also be copying whatever is making it break.
i’m going to copy everything one at a time so I can see what specifically is making it break.