Mobs weird functionality

I’m having a weird problem with making my mobs move with BodyVelocity. They either just continue going straight or get off path.They seem to work if I move and don’t work if I do and my friend has noticed this too.

local ss, rs, sss, players, cs, ps, ts  = getServices('ServerStorage', 'ReplicatedStorage','ServerScriptService', 'Players','CollectionService', 'PhysicsService','TweenService')
    mobModel:SetPrimaryPartCFrame(start.CFrame)
    --//Main Logic
    local function changeVelocityToNextPart(nextPart)
    	if nextPart then
    		local nextInt = tonumber(nextPart.Name)
    		local currentPart
    		if nextInt == nil then
    			local lastNum = #pathDir:GetChildren() - 2
    			currentPart = pathDir:FindFirstChild(tostring(lastNum))
    		else
    			local lastInt = nextInt - 1
    			if lastInt == nil or lastInt == 0 then
    				currentPart = pathDir.Start
    			else
    				currentPart = pathDir:FindFirstChild(tostring(lastInt))
    			end
    		end
    		if currentPart == nil then
    			currentPart = nextPart
    		end
    		spawn(function()
    			--ts:Create(mobModel.HumanoidRootPart, TweenInfo.new(.1), {Rotation=nextPart.Rotation}):Play()
    		end)
    		local nextPosition = nextPart.Position
    		if nextPosition.X > currentPart.Position.X then
    			Root.BodyVelocity.Velocity = Vector3.new(3,0,0)
    		elseif nextPosition.X < currentPart.Position.X then
    			Root.BodyVelocity.Velocity = Vector3.new(-3,0,0)
    		elseif nextPosition.Z > currentPart.Position.Z then
    			Root.BodyVelocity.Velocity = Vector3.new(0,0,3)
    		elseif nextPosition.Z < currentPart.Position.Z then
    			Root.BodyVelocity.Velocity = Vector3.new(0,0,-3)
    		end
    	end
    end
    function addHit(part)
    	local hitevent
    	hitevent = part.Touched:Connect(function(hit)
    		if hit:IsDescendantOf(mobModel) == false then return end
    		if hitevent then
    			hitevent:Disconnect()
    		end
    		if part.Name == "End" then
    			local health = mobModel.Stats.Health.Value
    			local mobs = _G.mobQueue
    			for i,v in pairs(mobs) do
    				if v == mobModel then
    					for ii, vv in pairs(mobs) do
    						if ii > i then
    							mobs[ii-1] = vv
    						end
    					end
    				end
    			end
    			mobModel:Destroy()
    			rs.Health.Value = rs.Health.Value - health
    		elseif part.Name ~= "End" then
    			local nextInt = tostring(tonumber(part.Name) + 1)
    			if nextInt then
    				local nextPart = pathDir:FindFirstChild(nextInt) or pathDir:FindFirstChild('End')
    				if nextPart then
    					changeVelocityToNextPart(nextPart)
    					addHit(nextPart)
    				end
    			end
    		end
    	end)
    end
    changeVelocityToNextPart(pathDir:FindFirstChild(currentIndex))
    local nextPart = pathDir:FindFirstChild(tostring(currentIndex+1)) or pathDir:FindFirstChild('End')
    if nextPart then
    	addHit(nextPart)
    end
    mobModel.Stats.Health.Changed:Connect(function(health)
    	if health <= 0 then
    		mobModel:Destroy()
    	end
    end)