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

Pathing script not moving character?

Asked by 3 years ago

I was trying to make a pathing script when it just didn't move. There are no errors.

local PathFindigService = game:GetService("PathfindingService")

local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")

local path = PathFindigService:CreatePath()
path:ComputeAsync(torso.position, game.Workspace.Part.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
end
1
I would use HumanoidRootPart instead of torso, r15 models don't have a torso. cmgtotalyawesome 1418 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I agree with what @cmgtotalyawesome said. R15 models have a "LowerTorso" and an "UpperTorso" while R6 models just have "Torso" so that is probably messing up your code. Every r6 and r15 have a HumanoidRootPart though. But the main problem I see here is, you say

human.MoveToFinished:Wait(2)

That number 2 is unnecessary, and it is messing up the code. I think you meant to say

human.MoveToFinished:Wait()
wait(2)

which waits until the move has finished, then waits 2 more seconds. Or you just want

human.MoveToFinished:Wait()

which just waits until the move has finished to continue the loop.

If that doesn't work then make sure that the NPC or model you are moving is not anchored (none of the limbs should be anchored)

hope this helps

1
Unfortunatly this hasn't helped I was already using r6 charaters and the wait function change didn't work. anything else Dragon_meck 15 — 3y
0
Did you check if the model was unanchored Omq_ItzJasmin 666 — 3y
0
yes sorry for not repling Dragon_meck 15 — 3y
0
Thats okay, I tried using your script with a Dummy and everything seemed to be working fine? ( https://vimeo.com/543342884 ) I do not think it is the script, maybe you messed something up with the character? Omq_ItzJasmin 666 — 3y
Ad
Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
3 years ago

Your using a torso to move, But the torso doesn't make you move, This is something in R6, R15, and rthro called a HumanoidRootPart it's basically a way to show Roblox where you are and it can move you so try this script.

local PathFindigService = game:GetService("PathfindingService")

local human = script.Parent:WaitForChild("Humanoid")
local rootPart = script.Parent:WaitForChild("HumanoidRootPart")

local path = PathFindigService:CreatePath()
path:ComputeAsync(rootPart.position, game.Workspace.Part.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
end
Log in to vote
0
Answered by 3 years ago
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(chr)
        local torso = chr:WaitForChild("Torso")
        local human = chr:WaitForChild("Humanoid")
        local pfs = game:GetService("PathfindingService")
        local ctorso = script.Parent:WaitForChild("Torso")
        local chuman = script.Parent:WaitForChild("Humanoid")
        local path = pfs:CreatePath()
        path:ComputeAsync(ctorso.Position, torso.Position)

        while true do
            chuman:MoveTo(torso.Position)
            wait(0.000001)
        end
    end)
end)

Answer this question