#MoveTo command skipping parts
1 messages · Page 1 of 1 (latest)
Maybe try moving the unit a few studs further in the direction of the current waypoint? I never tried something like this so its just an idea.
how do ı do that exactly?
I think there is another inbuild function called Humanoid:Move() which should just move the character forward.
Im not home right now so I can't really check
alr gl
movetofinished:wait() is a noob trap, do it properly: https://create.roblox.com/docs/characters/pathfinding
I already tried that, its really buggy but I kinda got it to work
it still cant turn properly though
local pfs = game:GetService("PathfindingService")
local unit = script.Parent
local humanoid = unit.Humanoid
local hrp = unit.HumanoidRootPart
local range = unit.Range
local found = 0
local path = pfs:CreatePath({
})
path:ComputeAsync(hrp.Position, workspace.EndPoint.Position)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for i, waypoint in waypoints do
local p = Instance.new("Part", workspace)
p.Position = waypoint.Position
p.Anchored = true
p.Material = Enum.Material.Neon
p.CanCollide = false
p.Size = Vector3.new(1,1,1)
end
end
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for i, waypoint in waypoints do
print("loop starting")
while found == 0 do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
range.Touched:Connect(function(man)
if man.Parent:FindFirstChild("Range") then
found = 1
end
end)
end
end
end
createpath is empty and you still have movetofinished:wait() in there
I also tried to make it stop when it touches something called range but it just doesnt move now
also there is no context to this code it appears to only run once
yeah, normally it makes a waypoint and starts walking there
when ı try to add anythig to the createpath for example
AgentCanJump = false
it straight up doesnt run
follow the roblox docs example
make blank humanoid move between 2 parts doesn't have to be fancy, get that working with the roblox docs code
ok, I'll try
maybe put a part in the way to show it actually pathfinding when you got it moving
when you finished that, apply what you learned to your current code
what counts is working. don't try to optimize or make it fancy, just make it work.
this page is really long
how am I supposed to follow this? I'm looking at the example but i can hardly understand it
also, this page also uses movetofinished
eh.... i guess it depends who you ask, it's not that long since most of it is code so it's more like a code reference for a few things
by reading it slowly and carefully, and following along with the samples in roblox studio
yes, it shows correct usage of movetofinished
notice how it says MoveToFinished:Connect and not MoveToFinished:Wait 
and if it takes you more than a day to get through it, that's normal. code is not an overnight thing, it takes time
this is why game dev takes so long ;o
80% of scripting is actually reading code, not writing it.
ohhh
ok thanks
@junior glade I tried adding movetofinished:connect but I failed a bit
can you help?
it just goes to the final waypoint
local unit = script.parent
local waypoints = workspace.Waypoints
for waypoint=1, #waypoints:GetChildren() do
unit.Humanoid:MoveTo(waypoints[waypoint].Position * Vector3.new(1,0,1))
unit.Humanoid.MoveToFinished:Connect(function()
waypoint =waypoint+1
end)
end
--local pos = waypoints[waypoint].Position * Vector3.new(1,0,1)
you cannot use the connection in the same way you would use movetofinished:wait() bruh
Im sorry I'm just tryna learn I've never done game developing before
there is no yield in this loop so it skips straight to the last one after reaching the first waypoint because you just made like a dozen connections to MoveToFinished
actually it doesn't even go to the first one, it goes to all of them immediately, it just happens the last waypoint is the last time moveto is called so that takes priority
oh
unit.Humanoid.MoveToFinished:Connect(function()
waypoint =waypoint+1
end)
``` and this does nothing. it's like you wrote this:
```lua
for i=1,100 do
i += 1 -- what does this even mean bro
end```
take a closer look at how the docs does it 👍
@junior glade I finally did it with movetofinished:connect but the problem is still happening. Its moving correctly to all the parts but its still not fully touchingthe turns and the one at the end
local unit = script.Parent
local humanoid = unit:FindFirstChild("Humanoid")
local waypoints = game.Workspace.Waypoints
local currentWaypoint = 1
humanoid.MoveToFinished:Connect(function(success)
if success then
currentWaypoint += 1
end
humanoid:MoveTo(waypoints[currentWaypoint].Position)
end)
humanoid:MoveTo(waypoints[currentWaypoint].Position)
I swear I got it right this time
moveto times out after 8 seconds you didn't capture that situation. it's in the docs, you left it out
wait
** You are now Level 10! **