Code not working (Still unsolved)

This makes the time take 5 seconds. You probably want to get the magnitude between the way points and use that distance to calculate how long you want the tween to take in order to get a constant move speed.

Since you have the cframe looking at waypoint+2 when you get to the end, the +2 doesn’t exist. So you need an if statement to handle that case. That is also why the character would be constantly adjusting to face the next way point, would probably be better to look at the target waypoint instead of the next one.

havent read the threads replies but you could recreate this behaviour by using tweens instead of using humanoid moveto. Then all you need to do is apply a looping animation to the character, this removes all your problems of it drifting or moving however it does. Tweening would also be far better in my opinion as this means you wouldn’t need to do all the extra things like setting collision groups so that faster tower defence mobs dont get stuck behind another one and push eachother

My problem with the time is I don’t really understand how I would accomplish that. For the +2 would I just change it to +1?

local ts = game:GetService("TweenService")
local character = script.Parent
local waypoints = workspace.Nodes

local HRTP = character.HumanoidRootPart
local CurrentWaypoint = waypoints[1].Position

for waypoint=2, #waypoints:GetChildren() do
  HRTP.CFrame =
  local NextWaypoint = waypoints[waypoint].Position
  local PostWaypoint = nil
  if waypoint+1 < #waypoints.GetChildren() then
    PostWaypoint = waypoints[waypoint+1].Position
    PostWaypoint = waypoints[waypoint].Position -- I don't recall if this produces any oddities with lookAt, if it does just change it to waypoint-1, or add an end part to the path to reference position from.
  local EquivalentTime = (CurrentWaypont - NextWaypoint).Magnitude / character.Humanoid.WalkSpeed -- see explanation below.
  local Info =,Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
  local twn = ts:Create(HRTP,,{CFrame =, PostWaypoint)})
  CurrentWaypoint = NextWaypoint

An explanation: We already know they will start at Waypoint 1 (if I recall correctly, otherwise, let me know.) So we can cache the position they’re supposed to be at and then set it first in the loop.
Next, we change the start of the for loop to 2 so we skip the 1st waypoint, and then we go on with our code.
Now we assign the variables for the position (to clean up our code) and we perform a conditional to make sure waypoint+1 is within the bounds of our folder’s size. If it is, we can reference that, else, check the code for a comment I left.
Now we simply recycle your section of the code.
And lastly, we assign the CurrentWaypoint variable as NextWaypoint since we have reached it.

Explanation for EquivalentTime:
We can calculate the magnitude (distance) between the current position and the goal and then divide it by our character’s walkspeed to get seconds it would take to reach it. Hope this is informative enough.

print(string.format("Cheers,\n\t%s\t[%s]", "IDoLua", "CantBeBothered"))
>>  IDoLua  [CantBeBothered]

This was incredibly helpful, just gotta test it but it looks very good!

After fixing a couple typos I am left with 1 error. When I run it it says:

Workspace.Growth.Script:19: Expected identifier when parsing expression, got ‘,’

It shows a red line under one of the commas but due to my unfamiliarity with tweens I am not sure what it is asking for. I tried putting Info in between the commas and it worked, but it was still easing, going different speeds, and turning weirdly

remove one of the commas

1 Like

I did but it said something about missing 3rd argument

Oh dear my bad, in between those commas put “Info”

I did, but then it had all the problems from before:
Identical Speed (I think, with easing it is hard to tell)
The odd rotation

1 Like

Hm… Sorry to say I’ve never encountered something where the character just oddly drifts…

I don’t think that I can provide much more support right now either, need sleep.

Have a nice sleep. However the issue is not with the drifting now that I have abandoned MoveTo. The issue is that it turns to face node C while moving between A and B, and that it eases, though I may have a solution for the easing that I will need to test tommorow

If this doesn’t work I’ll just stea- borrow ProfessionalBowie’s script, but I would prefer to have my own. Still, not a tragedy if there is no solution.

1 Like