On a local script, I use Humanoid:MoveTo()
, on an NPC’s character.
What I want to do is make
- My character moving to Point A
- NPC’s character moving to Point B
- Both at the same time.
However, everytime,
my character will move, and the NPC’s character will not.
I have absolutely no clue on what’s causing this. What makes it even more baffling, is that there would be a very small % chance that the NPC will move. It’d say about 2% of the time. (What I did was use the same code to test again and again)
Here’s the script for reference.
local function WalkToPoint(character,MovePoint) --MovePoint is the Vector3 itself
--// Create the path first
local waypoints = MakePathRemoteFunction:InvokeServer(character.PrimaryPart.Position,MovePoint)
if not waypoints then
error("Waypoints not found")
return
end
if not character.Humanoid or not character.Humanoid.Animator then
error("FUNCTION: WalkToPoint has stopped due to character not having a humanoid OR/AND an animator in the humanoid.")
return
end
for i, v in pairs(character.Humanoid.Animator:GetPlayingAnimationTracks()) do
v:Stop()
end
local connection
local newAnimation = Instance.new("Animation")
newAnimation.AnimationId = "rbxassetid://913376220" --3570535774 913376220
newAnimation.Name = "RunningAnimation"
newAnimation.Parent = character
local walkAnim = character.Humanoid:FindFirstChild("Animator"):LoadAnimation(newAnimation)
walkAnim:Play()
local NextWaypointIndex = 2
print(waypoints,character)
character.Humanoid.WalkSpeed = 16
for i, v in pairs(waypoints) do
print(character, v.Position)
connection = character.Humanoid.MoveToFinished:Connect(function(reached)
print(reached)
if reached and NextWaypointIndex < #waypoints then
NextWaypointIndex += 1
print("CHARACTER", character, "MOVED TO THE NEXT POINT")
else
print("Finished for character", character)
walkAnim:Stop()
character.Humanoid.WalkSpeed = 16
newAnimation:Destroy()
if connection then
print(NextWaypointIndex, #waypoints)
connection:Disconnect()
connection = nil
end
end
end)
character.Humanoid:MoveTo(v.Position)
end
character.Humanoid.WalkSpeed = 16
character.Humanoid:MoveTo(MovePoint)
I have checked and confirmed that:
- Humanoid Speed is not set to 0.
- Character parts are unanchored.
- Waypoints exists.
- All print statements printed.
- No errors in the Output.
Feel free to ask further questions, if I had not clarified anything clearly.
Thanks for taking your time out to read this. I appreciate it.