#Slow mob bug

1 messages · Page 1 of 1 (latest)

loud saddle
#

local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false

-- listen for the humanoid reaching its target
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
    targetReached = true
    connection:Disconnect()
    connection = nil
    if andThen then
        andThen(reached)
    end
end)

-- start walking
humanoid:MoveTo(targetPoint)

-- execute on a new thread so as to not yield function
task.spawn(function()
    while not targetReached do
        -- does the humanoid still exist?
        if not (humanoid and humanoid.Parent) then
            break
        end
        -- has the target changed?
        if humanoid.WalkToPoint ~= targetPoint then
            break
        end
        -- refresh the timeout
        humanoid:MoveTo(targetPoint)
        task.wait(6)
    end

    -- disconnect the connection if it is still connected
    if connection then
        connection:Disconnect()
        connection = nil
    end
end)

end

local function MoveMob(newMob, map)
if not newMob or not newMob.Parent then return end

local humanoid:Humanoid = newMob:FindFirstChildOfClass("Humanoid")
local root = newMob:FindFirstChild("HumanoidRootPart")
if not humanoid or not root then return end

local waypointsFolder = map:FindFirstChild("Waypoints")
if not waypointsFolder then return end

local waypoints = waypointsFolder:GetChildren()

table.sort(waypoints, function(a, b)
    return tonumber(a.Name) < tonumber(b.Name)
end)

for _,waypoint in ipairs(waypoints) do
    newMob.MovingTo.Value = tonumber(waypoint.Name)
    
    moveTo(humanoid, waypoint.Position)
    humanoid.MoveToFinished:Wait()
end

-- doszedł do bazy
if map:FindFirstChild("Base") and map.Base:FindFirstChild("Humanoid") then
    map.Base.Humanoid:TakeDamage(humanoid.MaxHealth)
end

newMob:Destroy()

end

#

somebody know wy my script dont work with slow enemys. When I set fast enemy it do everything good but slow enemy stop on random waypoint or skip it

real light
#

siema

#

add some debug prints to test when you use the slow enimies

#

so you can see what parts of the scripts are firing

#

and working

loud saddle
#

cześć

chrome tideBOT
#

studio** You are now Level 5! **studio

loud saddle
#

dobra spróbuje

#

it breaking in this moment:while not targetReached do
-- does the humanoid still exist?
if not (humanoid and humanoid.Parent) then
break
end
-- has the target changed?
if humanoid.WalkToPoint ~= targetPoint then
print("Target changed, breaking")
break
end
-- refresh the timeout
humanoid:MoveTo(targetPoint)
task.wait(6)

        print("not reached yet")
    end:        print("not reached yet")
#

print("not reached yet") ont his line (or under) it break

real light
#

on these lines:

-- disconnect the connection if it is still connected
if connection then
connection:Disconnect()
connection = nil
end

add another print under connection:Disconneect to see if it is disconnecting

#

which would explain why the slow mobs stop completely.

loud saddle
#

it dont disconnecting some times and wwhat can i do with this information?

real light
#

you need to debug your script