Hi, I want to make a NPC move randomly all around the map, and I'm using this code:

local home = script.Parent.Home
while true do
	wait(math.random(1,4))
	script.Parent.Humanoid:MoveTo(home.Position + Vector3.new(math.random(-10,10)), 0,home.Position + Vector3.new(math.random(-10,10)))
end

But, it doesn't work, and it says: 'Unable to cast value to object'. Can someone help me with this? ('Home' is a part attached to the NPC, and when the NPC moves, it should move with him)

3 comments

0

MoveTo has a Vector3 parameter, your X and Z are not points but instead are Vector3 values

0

yes

0

Thank you guys, now I see my mistake :)