I am making an ai wave system which makes entities move simultaneously under a condition
Here is what the movement function looks like
local function UpdateMovement()
if not workspace:GetAttribute("FightActive") then return end
print("Start")
for character in pairs(activeCharacters) do
task.spawn(function()
local humanoid = character:FindFirstChildOfClass("Humanoid")
local root = character:FindFirstChild("HumanoidRootPart")
if not humanoid or not root then return end
local isEnemy = character:IsDescendantOf(Enemies)
local targetFolder = isEnemy and Units or Enemies
local target, dist = GetNearestTarget(character, targetFolder)
if target and dist > STOP_DISTANCE then
local targetRoot = target:FindFirstChild("HumanoidRootPart")
if targetRoot then
print("GOOO")
humanoid:MoveTo(targetRoot.Position)
end
end
end)
end
end
If i were to run this on an NPC which has never moved before (npcs spawn with hrp anchored btw) it would take 4 seconds of heartbeat looping to get the entity to move
Once it moves for the first time, the next wave it moves instantly
How can i make the physics render on the humanoid on spawn (content provider did nothing)