Now, this code works fine and all, but the biggest issue that it will only start a single NPC when its supposed to make all of them start up and start doing whatever.
For example, theres 3 Mindless placed ingame, I press start, only one will do anything and the rest will remain idle.
for _, Mindless in collectionService:GetTagged("MindlessTitan") do
local mindlessTarget = nil
local MindlessHumanoid = Mindless:WaitForChild("Humanoid")
local MindlessPrimaryPart = Mindless:WaitForChild("HumanoidRootPart")
local walkTrack = MindlessHumanoid:LoadAnimation(MindlessWalk)
local idleTrack = MindlessHumanoid:LoadAnimation(MindlessIdle)
local titanPath = pathfindingService:CreatePath({
AgentRadius = 20 * Mindless:GetScale(),
AgentHeight = 29 * Mindless:GetScale(),
AgentCanJump = false,
AgentCanClimb = false,
WaypointSpacing = 44 * Mindless:GetScale()
})
MindlessHumanoid.Running:Connect(function(speed)
if speed > 0.1 then
walkTrack:Play()
idleTrack:Stop()
else
walkTrack:Stop()
idleTrack:Play()
end
end)
runService.Heartbeat:Connect(function()
SetMindlessTarget(Mindless, mindlessTarget, MindlessPrimaryPart, MindlessHumanoid, titanPath)
end)
mindlessTarget:FindFirstChild("Humanoid").Died:Connect(function()
SetMindlessTarget(Mindless, mindlessTarget, MindlessPrimaryPart, MindlessHumanoid, titanPath)
end)
end