Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Magnitude not working as expected?

Asked by 6 years ago

I am trying to make an NPC stop moving once it gets near the point it is moving to. According to the print, the magnitude is big enough to allow it to move. Why wouldnt it be working?

Here is my code:

--wait(30)

local nodes = game.Workspace.Nodes:GetChildren()
local pathService = game:GetService("PathfindingService")

while true do
    math.randomseed(tick())
    wait()
    randomNode = math.random(1, #nodes)
    path = pathService:ComputeRawPathAsync(script.Parent.DecalPart.Position, nodes[randomNode].Position, 10000)
    points = path:GetPointCoordinates()
    script.Parent.DecalPart.SweepSound:Play()
    for _, point in pairs(points) do
        script.Parent.SweepHumanoid:MoveTo(point)
        repeat wait() print((script.Parent.Head.Position - point).magnitude) until (script.Parent.Head.Position - point).Magnitude < 1
    end
end
0
Line14. The Humanoid MUST be called Humanoid to work. User#19524 175 — 6y
0
...No it doesn't... Its named sweephumanoid.... ronitrocket 120 — 6y
0
it worked with movetofinished:wait() but that lags in the actual game ronitrocket 120 — 6y
0
incapaz, it does not need to be fanofpixels 718 — 5y

Answer this question