Infinity yield occurs on a npc acceleration path find

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I wan’t to achieve to improve the infinity yield glitch that occurs on an npc acceleration path find which disturbs all the game.

  1. What is the issue? Include screenshots / videos if possible!

So once you join the game, the NPC pathfinder can find you because the glitch doesn’t occur yet, and everything is going precisely, but once it kills you, and you respawn, the NPC does not track you, or find you immediately, so it stays still, because, on its acceleration script, it doesn’t tell him to find you once again, so after you are dead, because there is an infinity yield and it can wait for 3 whole hours until it finds you, because is an unknown number.

Here is a video of what happens on the game:

Here is a photo of the script:

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

What I tried before
What i tried before is change the script and add an amount if time to it but nothing happened, and the infinity yield still occurred.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

local hum = script.Parent:WaitForChild(‘Humanoid’)
local hrp = script.Parent:WaitForChild(‘HumanoidRootPart’)
local preVel = nil

hum:GetPropertyChangedSignal(‘WalkToPoint’):Connect(function()
if preVel ~= nil then
if math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude)) == math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude)) then
if math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude)) >= math.rad(30) then
hum.WalkSpeed = 24/(math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude))+1)
else
hum.WalkSpeed = 24
end
end
end
preVel = hrp.Velocity
end)

It’s because script.Parent doesn’t have a child by the name “Humanoid”, so when you :WaitForChild() it will wait indefinitely. Thus an Infinite yield.

You can either rename the humanoid to “Humanoid” or you can do :FindFirstChildOfClass() instead.

2 Likes

The both waitforchild I change them or only one?

You can change them both since both the humanoid and humanoidrootpart will be there when the script runs.

But since HumanoidRootPart isn’t an instance type, you’d have to just use :FindFirstChild() for it.

So like this

local hum = script.Parent::FindFirstChildOfClass(‘Humanoid’)
local hrp = script.Parent::FindFirstChild(“HumanoidRootPart”)
local preVel = nil

hum:GetPropertyChangedSignal(‘WalkToPoint’):Connect(function()
if preVel ~= nil then
if math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude)) == math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude)) then
if math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude)) >= math.rad(30) then
hum.WalkSpeed = 24/(math.acos(hrp.Velocity:Dot(preVel)/(hrp.Velocity.Magnitude * preVel.Magnitude))+1)
else
hum.WalkSpeed = 24
end
end
end
preVel = hrp.Velocity
end)

Yes, but with :FindFirst… instead of ::FindFirst

Also you should use code blocks when posting your code on the forum.

-- like this

-- (by surrounding your code with ```)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.