I recently had this issue aswell, but only because I had never used npc's. Changing their walktopoint won't do anything, (No reason why)... But moveto() will. If your npc is flinging, it is likely because it is connected to the baseplate, try changing the npc's legs bottom surface to "Smooth" or "SmoothNoOutlines".
Requested Fix Code:
players = nil; dummy = game.Workspace.CitizenLvl1; currentPlayerFollowing = nil;
while wait(1) do
players = game.Players:GetChildren();
for i = 0, table.getn(players), 1 do
if (players[i] ~= nil and (math.abs(players[i].Character.Torso.Position.X - dummy.Torso.Position.X)) <= 10) then
currentPlayerFollowing = players[i];
end
end
if (currentPlayerFollowing ~= nil) then
dummy.Humanoid:MoveTo(currentPlayerFollowing.Character.Torso.Position)
end
end
Now, as far as improved code goes, I will now provide extra details to your code.
Improved+Details:
players,dummy,currentPlayerFollowing = nil,game.Workspace:WaitForChild("CitizenLvl1"),nil
while wait(1) do
players= game.Players:GetChildren()
for i=1,#players,1 do
if (players[i]~=nil and (players[i].Character.Torso.Position - dummy.Torso.Position).magnitude<= 10 then
currentPlayerFollowing= players[i]
end
end
if (currentPlayerFollowing~=nil) then
dummy.Humanoid:MoveTo(currentPlayerFollowing.Character.Torso.Position)
end
end
Improved(RAW):
players,dummy,currentPlayerFollowing = nil,game.Workspace:WaitForChild("CitizenLvl1"),nil
while wait(1) do
players= game.Players:GetChildren()
for i=1,#players,1 do
if (players[i]~=nil and (players[i].Character.Torso.Position - dummy.Torso.Position).magnitude<= 10 then
currentPlayerFollowing= players[i]
end
end
if (currentPlayerFollowing~=nil) then
dummy.Humanoid:MoveTo(currentPlayerFollowing.Character.Torso.Position)
end
end
~Taryo
1 comment
Thanks Taryo it worked!