#Npc not catching up to me

1 messages · Page 1 of 1 (latest)

exotic urchin
#

I want the NPC to catch up to me when pathfinding, but it's not working, or is it better to just increase the attack range in the module script?
Part of the module script:
Zombie = {
MaxHealth = 30,
WalkSpeed = 100,
JumpPower = 50,
AttackDamage = 10,
AttackCooldown = 3,
--KnockBackForce = 100,
wanderDistance = 15,
wanderCooldown = {2,5}, -- While wandering, walk in a random direction every _ to _ seconds
Range = 100,
AttackRange = 4,

    TimeBeforeDespawn = 150, --2.5 minutes
    RespawnCooldown = 150, -- 2.5 minutes

    DEBUGMODE = true,

    Costs = {
        Water = math.huge ,
        Neon = math.huge,
        Plastic = 1
    }

The file is the pathfinding script

latent coyote
#

try removing hum.MoveToFinished:Wait()

drowsy fossil
#

Just do when the player is close to the creature it shouldn't followthe waypoints instead ignore the waypoints and just move the humanoid to the closest player

exotic urchin
#

local targetRoot = target.Character and target.Character:FindFirstChild("HumanoidRootPart")
if targetRoot then
local distance = (HRP.Position - targetRoot.Position).Magnitude
if distance <= attackRange + 10 then
hum:MoveTo(targetRoot.Position)
break
end
end

like this?

dusky flax
#

You can make it so it moves towards the position that your character is going to be in a specific amount of time for example 0.5 seconds so it compensates like this:

local targetPosition = HumanoidRootPart.Position + HumanoidRootPart.AssemblyLinearVelocity * 0.5

knotty krakenBOT
#

studio** You are now Level 2! **studio

main pivot
#

Ts must be ChatGPT

dusky flax
#

It’s literally a basic part of making proper chasing npc’s

main pivot
#

"---------------------------------------------------------------------
-- OPTIMIZED WANDER SYSTEM

function wander()
if time() - lastWander >= randomWanderWait then
lastWander = time()
randomWanderWait = math.random(npcData.wanderCooldown[1], npcData.wanderCooldown[2])

    local randomOffset = Vector3.new(
        math.random(-npcData.wanderDistance, npcData.wanderDistance),
        0,
        math.random(-npcData.wanderDistance, npcData.wanderDistance)
    )
    local wanderTarget = HRP.Position + randomOffset

    local path = CreatePathToPosition(wanderTarget)
    if path then
        for _, waypoint in ipairs(path:GetWaypoints()) do
            hum:MoveTo(waypoint.Position)
            if waypoint.Action == Enum.PathWaypointAction.Jump then
                hum.Jump = true
            end
            hum.MoveToFinished:Wait()"