I have a loop going, making a NPC go back and forth, and whenever it begins to turn, it glitches and soon becomes looped to go only one direction. Can someone help me fix this?

local int = true
while true do
	if script.Parent:FindFirstChild("Head").Enlist.InUse == true then
		repeat
		script.Parent.Humanoid:Move(Vector3.new(0,0,0),false)
		until script.Parent.Head.Enlist.InUse == false
	elseif script.Parent.Head.Enlist.InUse == false then
	if int == true then
		script.Parent.Humanoid.MaxHealth = math.huge
		script.Parent.Humanoid.Health = math.huge
		script.Parent.Humanoid:Move(Vector3.new(1,0,0),false)
		wait(5)
		script.Parent.Humanoid:Move(Vector3.new(0,0,0),false)
		int = false
	elseif int == false then
		script.Parent.Humanoid.MaxHealth = math.huge
		script.Parent.Humanoid.Health = math.huge
		script.Parent.Humanoid:Move(Vector3.new(-1,0,0),false)
		wait(5)
		script.Parent.Humanoid:Move(Vector3.new(0,0,0),false)
		int = true
	end
	wait(1)
	end
	end

3 comments

0

Use position instead of move?

0

I want it to walk, and not teleport

0

Use :MoveTo