I made an NPC by clicking play game, copying it, and pasting it into workspace. The thing that's weird is that it doesn't seem to move when using the :MoveTo() command unless i give it a nudge, (There are no errors printing)

script:

local requestnewcords=coroutine.create(function()
	_G.genRandomX=math.random(-10,10)
	_G.genRandomY=math.random(-10,10)
	_G.genRandomZ=math.random(-10,10)
	print(_G.genRandomX,_G.genRandomY,_G.genRandomZ)
	_G.stepTime=_G.genRandomX+_G.genRandomZ/2
end)
local wander=coroutine.create(function()
	local loopCooldown=false
	while wander==true and loopCooldown==false do
		loopCooldown=true	
		coroutine.resume(requestnewcords)
		_G.lastpos=t.CFrame
		wait(math.random(5,10))
		hum:MoveTo(t.Position*Vector3.new(_G.genRandomX,0,_G.genRandomZ))
		loopCooldown=false
	end
end)

2 comments

0

(( It only moves if i move it with my character in-game or with my cursor in run mode))

0

use pathfinding to move a npc