I have a script which mimics the classic click-to-walk style of ROBLOX, but Humanoid:MoveTo()
doesn't seem to work.
m is PlayerMouse, p is player, h is Humanoid, g is just a random brick
print('Movement ' .. p.Name .. ' started.') h:MoveTo(Vector3.new(m.Hit.X, m.Hit.Y, m.Hit.Z), g)
...which fires on-click. I am positive it's a problem with the Humanoid:MoveTo()
, because everything else in the function works, including the print()
Is Humanoid:MoveTo()
broken?
No, it's not broken. Your problem is with m.Hit.X
.
The X
should actually be x
. That is, the properties are lowercase, not uppercase. So the fix for your code is:
h:MoveTo(Vector3.new(m.Hit.x, m.Hit.y, m.Hit.z), g)
But the thing is, you don't need to do what you're doing.
Saying Vector3.new(m.Hit.x, m.Hit.y, m.Hit.z)
is really just duplicating m.Hit.p
, so replace it with that:
h:MoveTo(m.Hit.p , g)